Skip to content

Instantly share code, notes, and snippets.

@mkp246
Last active October 28, 2022 05:43
Show Gist options
  • Save mkp246/f4eeed9bb446532495656421ce9f3f5f to your computer and use it in GitHub Desktop.
Save mkp246/f4eeed9bb446532495656421ce9f3f5f to your computer and use it in GitHub Desktop.
ctrl+space : always on top, ctrl+shift+c : copy selection path in explorer, ctrl+alt+t : launch cmd in current dir like ubuntu
#NoTrayIcon
#SingleInstance Force
SendMode "Input"
^Space:: WinSetAlwaysOnTop -1, WinExist("A")
^+c:: winExplorerGetSelectionPaths()
^!t:: launchCmd()
winExplorerGetSelectionPaths() {
if(WinActive("ahk_class CabinetWClass")) {
windowHandle := WinExist("A")
for window in ComObject("Shell.Application").Windows
if (window.hwnd == windowHandle)
items := window.Document.SelectedItems
for item in items
selection .= item.path "`n"
if(selection){
;write it to clipboard to be used by ctrl+V later
A_clipboard := selection
}
}
}
launchCmd(){
if(WinActive("ahk_class CabinetWClass")) {
windowHandle := WinActive("A")
cwd := ControlGetText("ToolbarWindow323", "ahk_id" windowHandle)
cwd := SubStr(cwd, 10)
secondChar := Substr(cwd, 2, 1)
;check if cwd is special path
;MsgBox cwd
if(StrCompare(secondChar, ":")) {
;don't run if special dir, can't figure out which dir exactly
;cwd:= EnvGet("HOMEDRIVE") . EnvGet("HOMEPATH")
} else {
run("cmd", cwd)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment