AutoHotkey (AHK) - open programs
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
SwitchToWindowsTerminal() | |
{ | |
windowHandleId := WinExist("ahk_exe WindowsTerminal.exe") | |
windowExistsAlready := windowHandleId > 0 | |
; If the Windows Terminal is already open, determine if we should put it in focus or minimize it. | |
if (windowExistsAlready = true) | |
{ | |
activeWindowHandleId := WinExist("A") | |
windowIsAlreadyActive := activeWindowHandleId == windowHandleId | |
if (windowIsAlreadyActive) | |
{ | |
; Minimize the window. | |
WinMinimize, "ahk_id %windowHandleId%" | |
} | |
else | |
{ | |
; Put the window in focus. | |
WinActivate, "ahk_id %windowHandleId%" | |
WinShow, "ahk_id %windowHandleId%" | |
} | |
} | |
; Else it's not already open, so launch it. | |
else | |
{ | |
Run wt | |
} | |
} | |
; Hotkey to use Win+Q to launch/restore the Windows Terminal. | |
#q::SwitchToWindowsTerminal() | |
SwitchToKeePassXC() | |
{ | |
windowHandleId := WinExist("ahk_exe KeePassXC.exe") | |
windowExistsAlready := windowHandleId > 0 | |
; If the KeePassXC is already open, determine if we should put it in focus or minimize it. | |
if (windowExistsAlready = true) | |
{ | |
activeWindowHandleId := WinExist("A") | |
windowIsAlreadyActive := activeWindowHandleId == windowHandleId | |
if (windowIsAlreadyActive) | |
{ | |
; Minimize the window. | |
WinMinimize, "ahk_id %windowHandleId%" | |
} | |
else | |
{ | |
; Put the window in focus. | |
WinActivate, "ahk_id %windowHandleId%" | |
WinShow, "ahk_id %windowHandleId%" | |
} | |
} | |
; Else it's not already open, so launch it. | |
else | |
{ | |
EnvGet, ProgramFiles32, ProgramFiles(x86) | |
EnvGet, ProgramFiles64, ProgramFiles | |
if (!ProgramFiles32) | |
ProgramFiles32 := ProgramFiles64 | |
Run % ProgramFiles64 . "\KeePassXC\KeePassXC.exe" | |
} | |
} | |
; Run/show/hide KeePassXC using Win+K | |
#K::SwitchToKeePassXC() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment