Skip to content

Instantly share code, notes, and snippets.

@mkropat
Created January 30, 2017 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkropat/6204b96e21d60b8b31377386d3947571 to your computer and use it in GitHub Desktop.
Save mkropat/6204b96e21d60b8b31377386d3947571 to your computer and use it in GitHub Desktop.
^!r::Reload
RunOrRaise(caption) {
r := ComObjGet("winmgmts:")
.ExecQuery("SELECT Handle FROM Win32_Process WHERE Caption='" . caption . "'")
If r._NewEnum()[proc]
{
;WinGet, windows, list
;Loop, %windows%
;{
; id := windows%A_Index%
; WinGet pid, PID, % "ahk_id " id
; If (proc.Handle = pid)
; {
; WinActivate, ahk_id %id%
; Return
; }
;}
pid := proc.Handle
WinActivate, ahk_pid %pid%
}
Else
{
Run, %caption%
}
r := ""
}
^!c::RunOrRaise("chrome.exe")
^!f::RunOrRaise("firefox.exe")
^!g::RunOrRaise("gvim.exe")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment