How to collect arguments from multiple instances of autohotkey script and pass it to handler script?

71 Views Asked by At

The actual thing I did and want to do:

  1. I have a autohotkey script 1.ahk that do something with directory, something like:

    #Requires Autohotkey v2.0
    if(A_Args.length > 0){
        srcFolderPath := A_Args[1]
        DoSomethingWithPath(srcFolderPath)
    }
    
  2. I add a custom contextmenu item (windows 10) for it in HKCR\Directory\shell\DoThing\command, the value is "C:\App\AutoHotkey.exe" "C:\Script\1.ahk" "%1", then when I select a folder folder1 then right click and choose DoThing, 1.ahk is called and received the full path of folder1 as argument

  3. However when I select multiple folders folder1 ... folder99 then right click and select DoThing, 1.ahk is called 99 times, there're possible 99 overwrite/readonly warning which I wanto avoid

  4. [Goal] I want 1.ahk to receive an array of arguments that contains 99 path strings instead of call 1.ahk 99 times when I select 99 folders and click DoThing, change 1.ahk to

    #Requires Autohotkey v2.0
    if(A_Args.length > 0){
        srcFolderPathArray := A_Args
        DoSomethingWithPathArray(srcFolderPathArray)
    }
    

If possible I want avoid method like "99 instances write to temp.txt and 1.ahk read it"

Or is it possible to pass all arguments as array in the beginning?

Thanks for any help of advice

0

There are 0 best solutions below