Jean Lalonde Support Forum

Full Version: How to Copy or Move the selected file to a favorite folder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In reading the release notes for 11.5.7, it says and shows the ability to Move or Copy a selected file.

How is they added? I don't find them when Adding a Favorite.

Thank you.
Hi Dale,

I'll do a video on this with Joe Glines in the next week. In the mean time, you can read this about Alternative menu features.

Jean
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.

Salut Jean,
Last week, I also made a script to move selected files/folders with QAP. It can move multiples selected files/folders from the desktop/Windows file explorer. It doesn't work the same way as yours, so maybe it can give you new ideas.

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. The workaround is to not click in the "main window" of Windows file explorer but to click anywhere else to open the QAP Menu, in the ribbons area for example. This way the files/folders are not deselecting.

It doesn't behave the same way on the desktop. On the desktop, the files/folders are deselecting but the script still "remembers" the files/folders.

You can take a look and try it. It's an amateur script and not fully tested.

Bonne fin de semaine !

Code:
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
}
Bonjour Jean-Baptiste,

(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.

It is not necessary to assign a hotkey to these features. The simplest way is to open the Alternative menu with "Shift+Middle Mouse button" and then select the "Move/Copy selected item". Of course, assigning a hotkey or using a keyboard modifier key can make it faster to launch. I'll explain in the video next week.

(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.

Yes. In fact, QAP is selecting the file under the cursor when you open the menu. Doing this, it deselects your multiple selection. This was done a long time ago for various reasons: to make sure the window under the cursor is active (this could be done differently now that it could be an issue) and to make sure a file is selected for various QAP features. I noted a to-do for this. But, for now, you can avoid it by launching your script with the Alternative menu (Shift+Middle mouse button), then select "Open in a new window" and select your script. That way the files are not deselected.

And thanks for your script. I'm also adding a to-do to support multiple files/folders selection in the new "Move/Copy Selected file" feature.

Bonne fin de semaine,
Jean


Bonne fin de semaine !
Here is the video about the Alternative menu showing how to Copy or Move the selected file to a favorite folder:
https://forum.quickaccesspopup.com/showt...p?tid=2046
(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.

Hi Jean Baptiste,

This "deselect" issue has been fixed in release v11.5.7.1.

Jean