Skip to content

Instantly share code, notes, and snippets.

@Konfekt
Last active April 9, 2024 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Konfekt/953ea77111067d355b497a973ade15d4 to your computer and use it in GitHub Desktop.
Save Konfekt/953ea77111067d355b497a973ade15d4 to your computer and use it in GitHub Desktop.
Autohotkey v2 Script to Run or Raise application using Shortcut
; Run or Raise Application using Shortcut
; From https://gist.github.com/dewaka/c494543b4cd2a2dcd09cc5a6aa0f7517 adapted to ah2
RunOrRaise(exePath, winID:="") {
if (winID == "") {
exeName := SubStr(exePath, InStr(exePath, "\", , -1)+1)
winID := "ahk_exe " . exeName
}
If not WinExist(winID) {
UserProfile := EnvGet("USERPROFILE")
Try Run(exePath, UserProfile, "", )
WinWait(winID)
Try WinActivate()
}
else {
If WinExist(winID) {
If WinActive() {
WinWait(winID)
Try WinMinimize()
}
else {
WinWait(winID)
Try WinActivate()
}
}
}
}
#.::
{
PATH := EnvGet("PATH")
Commander_Path := EnvGet("COMMANDER_PATH")
RunOrRaise("totalcmd64.exe", "ahk_class TTOTAL_CMD")
Return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment