I have two AutoHotKey scripts. The first, explorer_select_Win, saves a list of file paths for all the files I had selected in an explorer window at the time I press the Windows key. This list is saved to C:\selection.txt.
The second script, selectionRUN, takes a given command (such as one would type in the command line) and executes it for each file listed in selection.txt. An example is the easiest way to explain this:
I have a program called md5sum.exe (Google md5sums for Windows) that calculates the md5sum for the specified file. I setup start++ to run the command "selectionRUN.exe" with arguments "md5sums.exe" %* and start++ shortcut "md5sum". I have my selection saving script running and waiting. Now, to compute the md5sum of any files, I just select them in a normal explorer window, press the Windows key, and type md5sum -p. (the -p argument is for md5sum.exe. It tells it to pause before exiting).
Below is all the code. I haven't done much to clean it up or document it, but its pretty straight forward. selectionRun isn't as flexible as it should be, but it shows the general idea. I thought it would be best to let others have fun with it (and see what they come up with), rather than sitting on it until I have time to work on it again.
hope someone finds it useful!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``
;selectionRun.ahk
;Runs the specified file using the file names in selection.txt
;as the first parameter. Other specified arguments are added
;at the end.
;command (after compiled):
; selectionRun.exe <program> <program arguments>
;effective command (for each filename in selection.txt):
;<program> <file_name> <other_arguments>
parameters=%A_Space%
Loop, %0%
{
if (A_Index=1)
continue
param := %A_Index%
parameters=%parameters% %param%
}
Loop,read,C:\selection.txt
{
runwait,%1% %A_LoopReadLine% %parameters%
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;explorer_select_Win.ahk
;much of this is from the AHK documentation
#IfWinActive ahk_class ExploreWClass
LWin::
explorerClass = ExploreWClass
Goto ExplorerExtension
#IfWinActive ahk_class CabinetWClass
LWin::
explorerClass = CabinetWClass
Goto ExplorerExtension
#IfWinActive
ExplorerExtension:
ControlGetText currentPath, Edit1, ahk_class %explorerClass%
selectedFile := GetExplorerSelectedFile()
GetExplorerSelectedFile()
{
local selectedFiles, file
FileDelete, C:\Selection.txt
WinGetClass explorerClass, A
ControlGetText currentPath, Edit1, ahk_class %explorerClass%
ControlGet, selectedFiles, List, Selected Col1, SysListView321, ahk_class %explorerClass%
Loop, Parse, selectedFiles, `n ; Rows are delimited by linefeeds (`n).
{
file := A_LoopField
FileAppend, %currentPath%\%file%`n, C:\Selection.txt
}
Send {LWin}
return
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~