On this forum helped me one member with creating part of script which after calling scans selected file(s) and when I press hotkey they're opened in program associated with hotkey.
Example of hotkey:
Code: Select all
vk7Fsc067::
this_path := Selected_Files() ; calling selected file scan
Run, paint.exe "%this_path%" ; opening file in MS Paint
return
I need to detect if is file not selected by return string something like "<nofile>" and avoid ask or program termination.
Here's code of scan routine (has two parts - one for Explorer and one for Desktop):
Code: Select all
Selected_Files()
{
; Handles Explorer
IfWinActive, ahk_class CabinetWClass
{
for window in ComObjCreate("Shell.Application").Windows
if window.HWND = WinExist("A")
this_window := window
; If multiple Items selected
if(this_window.Document.SelectedItems.Count > 1)
{
these_files := ""
for item in this_window.Document.SelectedItems
these_files .= item.Path . "`n"
return these_files
}
else
return this_window.Document.FocusedItem.Path
}
; Handles Desktop
if(WinActive("ahk_class Progman") || WinActive("ahk_class WorkerW"))
{
ControlGet, selectedFiles, List, Selected Col1, SysListView321, A
; If multiple Items selected
if InStr(selectedFiles, "`n")
{
these_files := ""
Loop, Parse, selectedFiles, `n, `r
these_files .= A_Desktop . "\" . A_LoopField . "`n"
return these_files
}
else
return A_Desktop . "\" . selectedFiles
}
else
return false
}
Thank you for all.
Miro