dr Winchell > 2022-05-26 17:46
Jean Lalonde > 2022-05-27 07:52
Jean Baptiste > 2022-05-27 23:57
Explorer_GetSelection()
if (!SelectedFiles) or (SelectedFiles = A_Desktop) {
ExitApp
}
SelectFolderEx()
if (!SelectedFolder) {
ExitApp
}
MsgBox, 36,, %SelectedFiles%`nMove to:`n%SelectedFolder%
IfMsgBox No
ExitApp
Loop, parse, SelectedFiles, `n
{
if (!A_LoopField) or (A_LoopField := A_Desktop) {
ExitApp
}
else {
AttributeString := FileExist(A_LoopField)
if (AttributeString = "D") {
SplitPath, A_LoopField,,,, Folder
FileMoveDir, %A_LoopField%, %SelectedFolder%\%Folder%
}
else {
FileMove, %A_LoopField%, %SelectedFolder%
}
}
}
return
SelectFolderEx(StartingFolder := "", Prompt := "", OwnerHwnd := 0, OkBtnLabel := "") {
global
Static OsVersion := DllCall("GetVersion", "UChar")
, IID_IShellItem := 0
, InitIID := VarSetCapacity(IID_IShellItem, 16, 0)
& DllCall("Ole32.dll\IIDFromString", "WStr", "{43826d1e-e718-42ee-bc55-a1e261c37bfe}", "Ptr", &IID_IShellItem)
, Show := A_PtrSize * 3
, SetOptions := A_PtrSize * 9
, SetFolder := A_PtrSize * 12
, SetTitle := A_PtrSize * 17
, SetOkButtonLabel := A_PtrSize * 18
, GetResult := A_PtrSize * 20
SelectedFolder := ""
If (OsVersion < 6) { ; IFileDialog requires Win Vista+, so revert to FileSelectFolder
FileSelectFolder, SelectedFolder, *%StartingFolder%, 3, %Prompt%
Return SelectedFolder
}
OwnerHwnd := DllCall("IsWindow", "Ptr", OwnerHwnd, "UInt") ? OwnerHwnd : 0
If !(FileDialog := ComObjCreate("{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}", "{42f85136-db7e-439c-85f1-e4075d135fc8}"))
Return ""
VTBL := NumGet(FileDialog + 0, "UPtr")
; FOS_CREATEPROMPT | FOS_NOCHANGEDIR | FOS_PICKFOLDERS
DllCall(NumGet(VTBL + SetOptions, "UPtr"), "Ptr", FileDialog, "UInt", 0x00002028, "UInt")
If (StartingFolder <> "")
If !DllCall("Shell32.dll\SHCreateItemFromParsingName", "WStr", StartingFolder, "Ptr", 0, "Ptr", &IID_IShellItem, "PtrP", FolderItem)
DllCall(NumGet(VTBL + SetFolder, "UPtr"), "Ptr", FileDialog, "Ptr", FolderItem, "UInt")
If (Prompt <> "")
DllCall(NumGet(VTBL + SetTitle, "UPtr"), "Ptr", FileDialog, "WStr", Prompt, "UInt")
If (OkBtnLabel <> "")
DllCall(NumGet(VTBL + SetOkButtonLabel, "UPtr"), "Ptr", FileDialog, "WStr", OkBtnLabel, "UInt")
If !DllCall(NumGet(VTBL + Show, "UPtr"), "Ptr", FileDialog, "Ptr", OwnerHwnd, "UInt") {
If !DllCall(NumGet(VTBL + GetResult, "UPtr"), "Ptr", FileDialog, "PtrP", ShellItem, "UInt") {
GetDisplayName := NumGet(NumGet(ShellItem + 0, "UPtr"), A_PtrSize * 5, "UPtr")
If !DllCall(GetDisplayName, "Ptr", ShellItem, "UInt", 0x80028000, "PtrP", StrPtr) ; SIGDN_DESKTOPABSOLUTEPARSING
SelectedFolder := StrGet(StrPtr, "UTF-16"), DllCall("Ole32.dll\CoTaskMemFree", "Ptr", StrPtr)
ObjRelease(ShellItem)
} }
If (FolderItem)
ObjRelease(FolderItem)
ObjRelease(FileDialog)
Return SelectedFolder
}
Explorer_GetSelection() {
Global
WinGetClass, winClass, % "ahk_id" . hWnd := WinExist("A")
if (winClass ~= "Progman|WorkerW")
oShellFolderView := GetDesktopIShellFolderViewDual()
else if (winClass ~= "(Cabinet|Explore)WClass") {
for window in ComObjCreate("Shell.Application").Windows
if (hWnd = window.HWND) && (oShellFolderView := window.document)
break
}
else
Return
for item in oShellFolderView.SelectedItems
SelectedFiles .= (SelectedFiles = "" ? "" : "`n") . item.path
if !SelectedFiles
SelectedFiles := oShellFolderView.Folder.Self.Path
Return SelectedFiles
}
GetDesktopIShellFolderViewDual()
{
IShellWindows := ComObjCreate("{9BA05972-F6A8-11CF-A442-00A0C90A8F39}")
desktop := IShellWindows.Item(ComObj(19, 8)) ; VT_UI4, SCW_DESKTOP
; Retrieve top-level browser object.
if ptlb := ComObjQuery(desktop
, "{4C96BE40-915C-11CF-99D3-00AA004AE837}" ; SID_STopLevelBrowser
, "{000214E2-0000-0000-C000-000000000046}") ; IID_IShellBrowser
{
; IShellBrowser.QueryActiveShellView -> IShellView
if DllCall(NumGet(NumGet(ptlb+0)+15*A_PtrSize), "ptr", ptlb, "ptr*", psv) = 0
{
; Define IID_IDispatch.
VarSetCapacity(IID_IDispatch, 16)
NumPut(0x46000000000000C0, NumPut(0x20400, IID_IDispatch, "int64"), "int64")
; IShellView.GetItemObject -> IDispatch (object which implements IShellFolderViewDual)
DllCall(NumGet(NumGet(psv+0)+15*A_PtrSize), "ptr", psv
, "uint", 0, "ptr", &IID_IDispatch, "ptr*", pdisp)
IShellFolderViewDual := ComObjEnwrap(pdisp)
ObjRelease(psv)
}
ObjRelease(ptlb)
}
return IShellFolderViewDual
}
Jean Lalonde > 2022-05-28 10:39
(2022-05-27 23:57)Jean Baptiste Wrote: Hi dr Winchell,
It's in the options. Options - Alternative Menu Hotkeys - Move the selected file to a favorite folder. You need to give it a Hotkey.
(2022-05-27 23:57)Jean Baptiste Wrote: The only small issue with the script right now is in Windows file explorer. When I open the QAP Menu with the hotkey, it's deselecting the files/folders and the script doesn't "remember" them.
Jean Lalonde > 2022-06-01 17:53
Jean Lalonde > 2022-07-13 15:46
(2022-05-27 23:57)Jean Baptiste Wrote: The only small issue with the script right now is in Windows file explorer. When I open the QAP Menu with the hotkey, it's deselecting the files/folders and the script doesn't "remember" them.