Last active
April 9, 2024 12:26
-
-
Save Konfekt/953ea77111067d355b497a973ade15d4 to your computer and use it in GitHub Desktop.
Autohotkey v2 Script to Run or Raise application using Shortcut
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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