Jean Lalonde Support Forum

Full Version: error with advanced settings for favorite folder/file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Jean,

I wanted to get advantage of advanced settings for favorites folder, and passe folder path as a parameter for AHK. I tried to get params from AHK by launchiung a script. I also tried to example you give under https://www.quickaccesspopup.com/what-ar...e-folders/

In both case I got an error message from file explorer (cf attachement)


The batch code is :
Code:
c:
cd \
echo List files in %1
dir %1
pause

AHK code is :

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode,2
; #Persistent
#SingleInstance Force
#WinActivateForce

Sysget, totalWidth, 78
Sysget, totalHeight, 79

MsgBox %1%

Loop, %0%  ; For each parameter:
{
    param := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
    MsgBox, 4,, Parameter number %A_Index% is %param%.  Continue?
    IfMsgBox, No
        break
}

; msgbox %explorerpath%

for n, param in A_Args  ; For each parameter:
{
    explorerpath = %param%
}
; explorerpath = %A_ScriptDir%



Msgbox before %explorerpath%

DetectCtrKeyIsDown  := GetKeyState(LCtrl , P)

Msgbox after : %DetectCtrKeyIsDown%


Return

My ultimate goal is to link a macro to some favorite folders, in order to  perform a fast sorting of files :

  1. select a document or a folder in explorer
  2. launch QAP favorite folder with a macro linked to it
  3. move selection from 1 to corresponding folder 2.
  4. in some cases launch a dialog or a menu to change document name, with structure personalized based on destination folder
That would be like using QAP as simple DMS.

Any suggestions regarding my goal would be welcome !
Hi,

In Advanced parameters, did you enclose the folder path between double-quotes?
(2022-07-18 07:12)Jean Lalonde Wrote: [ -> ]Hi,

In Advanced parameters, did you enclose the folder path between double-quotes?

Yes, I did like this :
"C:\Users\USERNAME\OneDrive\20-Batches\qapparam.bat"


same error
Hi Gio710,

Sorry, I looked at your script and could not understand what you are trying to do exactly and I don't have much time to investigate this. Does your script run correctly from the command-line (without QAP)? If yes, give an example of the command line and parameters running your script. With this, it could be easier to help you integrate this in QAP.

Also, if you need more help on AHK scripting, I recommend asking the AHK forum where there are more people able to help you.
(2022-08-02 13:20)Jean Lalonde Wrote: [ -> ]Hi Gio710,

Sorry, I looked at your script and could not understand what you are trying to do exactly and I don't have much time to investigate this. Does your script run correctly from the command-line (without QAP)? If yes, give an example of the command line and parameters running your script. With this, it could be easier to help you integrate this in QAP.

Also, if you need more help on AHK scripting, I recommend asking the AHK forum where there are more people able to help you.

Hi Jean,

I hgave finished the AHK macro I need to launch from QAP, when associated to some folders as an app, and need these folder to be passed as a parameter. 

This Macro is made to send selected file in win explorer to the QAP folder that will be selected by calling QAP.
Example : if I scan my bills, and that these scans are always written to the same windows folder, I will want to sort to various folders for different bills type. Therefore I put all these folders in a QAP menu.

So when I have finished scanning my bills, then I will select them one by one in the scan folder. Then, while maintaining Left ctrl pressed, I'll launch QAP with middle mouse button,
select the destination folder for my selected file.

Therefore, I need to be able to send the QAP folder path as a parameter to the above macro; when this macro receives the path as a parameter AND Left ctrl stay pressed, this ahk macro sends selected file to the destination folder.


Thats like a simplified DMS function

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode,2
; #Persistent
#SingleInstance Force
#WinActivateForce

Sysget, totalWidth, 78
Sysget, totalHeight, 79


; This Macro is made to send selected file in win explorer to the QAP folder that will be selected
; example : if I scan my bills, and that these scans are written a window folder
; I will use the various folders for different bills type, that I put in a QAP menu
; So when I have finished scanning my bills, then I will select them one by one
; then, while maintaining Left ctrl pressed, I'll launch QAP with middle mouse button
; select the destination folder for my selected file

; Therefore, I need to be able to send the folder path as a parameter to this macro
; when this macro receives the path as a parameter AND Left ctrl stay pressed,
; this ahk macro sends selected file to the destination folder



FNBR := WinExplorer_GetSelectionDirAndPath()

; MsgBox paramètre 1 -  %1%

; Loop, %0%  ; For each parameter:
; {
;     param := %A_Index%  ; Fetch the contents of the variable whose name is contained in A_Index.
;     ; MsgBox, 4,, Parameter number %A_Index% is %param%.  Continue?
;     ; IfMsgBox, No
;         ; break
; }

; msgbox %explorerpath%

for n, param in A_Args  ; For each parameter:
{
    PathToMoveSelectionTo = %param%
}
; explorerpath = %A_ScriptDir%




if GetKeyState("LCtrl")  ; LControl is still down.
    MsgBox La touche contrôle est restée appuyée`n=> Depuis QAP, le dossier vers lequel envoyer la sélection est %PathToMoveSelectionTo%
    FileMove, % FNBR.Path, % PathToMoveSelectionTo, 1
    return  ; Do nothing.

; Msgbox after : %DetectCtrKeyIsDown%


Return

WinExplorer_GetSelectionDirAndPath(hwnd="") {
    WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
    WinGetClass class, ahk_id %hwnd%
    if  (process = "explorer.exe")
        if (class ~= "(Cabinet|Explore)WClass") {
            for window in ComObjCreate("Shell.Application").Windows
                if  (window.hwnd==hwnd)
                    FilePath := window.Document.FocusedItem.path
                   

            SplitPath, FilePath, FileNameExt, FileDir, XT, FileNameNoExt   
            ; msgbox FilePath=%FilePath%`n`nFileNameExt=%FileNameExt%`n`nFileDir=%FileDir%`n`nExtension=%XT%`n`nFileNameNoExt=%FileNameNoExt%
            ; return
            ; FilePath == absolute path  with name and extension
            ; FileDir == absolute path  without name ;
            ; FileNameExt == File Name, with extension included
            ; FileNameNoExt == File Name, without extension
            ; FileNameExt := FileNameNoExt . "." . XT
        }
        Sel:={Dir: FileDir, NameNo: FileNameNoExt, NameExt: FileNameExt, Path: FilePath, Ext: XT}
        return Sel
}
If I get you well, you have a menu with folders and you would like to pass the selected folder as a parameter to your AHK script. The way to do it is, for each favorite folder in this menu, in Advanced Parameters, enter the path to your .AHK script. That way, when you select the folder, your script will be called and the path to the folder will be passed to it as the first parameter. But note that these folder favorites would be dedicated to this task. They could not be used to open the folders normally.

About advanced parameters, see: https://www.quickaccesspopup.com/what-ar...-settings/
HI Jean, that's it.

The difficulty I have right now, is that when I save a folder as a favorite, it's advanced setting in QAP does not have the parameter field, like I have it with an app as a favorite.

I would like to be able to start it with an AHK macro, and let the macro decide whether the folder would be opened or it it's path would only be used via a parameter variable
> when I save a folder as a favorite, it's advanced setting in QAP does not have the parameter field, like I have it with an app as a favorite.

True. Folders cannot receive parameters. In my suggestion, I forgot to mention to put the path to your script in the "Launch with this application" field.