When selecting a file and pressing a key combination, I want it to give me the option to choose which program to open it with.
Thanks in advance!
Choosing to open a file with a specific program Topic is solved
Re: Choosing to open a file with a specific program
Code: Select all
prog := ["notepad.exe", "chrome.exe"]
SetTitleMatchMode, RegEx
Menu, progs, Add, Open in Notepad, Open
Menu, progs, Add, Open in Chrome, Open
#IfWinActive ahk_class (Cabinet|Explore)WClass
F3::Menu, progs, Show
#IfWinActive
Open:
For each, file in getSelected()
Run, % prog[A_ThisMenuItemPos] " """ file """"
Return
getSelected() { ; https://www.autohotkey.com/boards/viewtopic.php?style=17&t=60403#p255256 by teadrinker
hwnd := WinExist("A"), selection := []
WinGetClass, class
If (class ~= "(Cabinet|Explore)WClass")
For window in ComObjCreate("Shell.Application").Windows
If (window.hwnd = hwnd)
For item in window.document.SelectedItems
selection.Push(item.Path)
Return selection
}
Re: Choosing to open a file with a specific program
It works well. Is there a way to make it work on desktop as well?mikeyww wrote: ↑20 Jan 2022, 10:08Alternative: right-click -> "Open with..."Code: Select all
prog := ["notepad.exe", "chrome.exe"] Menu, progs, Add, Open in Notepad, Open Menu, progs, Add, Open in Chrome, Open #If explorer() F3::Menu, progs, Show #If Open: For each, file in getSelected() Run, % prog[A_ThisMenuItemPos] " """ file """" Return getSelected() { ; https://www.autohotkey.com/boards/viewtopic.php?style=17&t=60403#p255256 by teadrinker hwnd := WinExist("A"), selection := [] For window in ComObjCreate("Shell.Application").Windows If (window.hwnd = hwnd) For item in window.document.SelectedItems selection.Push(item.Path) Return selection } explorer() { WinGetClass, class, A Return class ~= "(Cabinet|Explore)WClass" }
Re: Choosing to open a file with a specific program Topic is solved
Code: Select all
prog := ["notepad.exe", "chrome.exe"]
SetTitleMatchMode, RegEx
Menu, progs, Add, Open in Notepad, Open
Menu, progs, Add, Open in Chrome, Open
#IfWinActive ahk_class CabinetWClass|ExploreWClass|WorkerW|Progman
F3::Menu, progs, Show
#IfWinActive
Open:
For each, file in getSelected()
Run, % prog[A_ThisMenuItemPos] " """ file """"
Return
getSelected() { ; https://www.autohotkey.com/boards/viewtopic.php?style=17&t=60403#p255256
hwnd := WinExist("A"), selection := []
WinGetClass, class
Switch
{ Case class ~= "(Cabinet|Explore)WClass":
For window in ComObjCreate("Shell.Application").Windows
If (window.hwnd = hwnd)
For item in window.document.SelectedItems
selection.Push(item.Path)
Case class ~= "Progman|WorkerW": ; https://www.autohotkey.com/boards/viewtopic.php?p=154836#p154836
oWindows := ComObjCreate("Shell.Application").Windows, VarSetCapacity(hWnd, 4, 0)
oWin := oWindows.FindWindowSW(0, "", SWC_DESKTOP := 8, ComObject(0x4003, &hWnd), SWFO_NEEDDISPATCH := 1)
For oItem in oWin.Document.SelectedItems
If SubStr(oItem.path, 1, 3) != "::{"
selection.Push(oItem.Path)
}
Return selection
}