Skip to content

Instantly share code, notes, and snippets.

@shaun-sweet
Last active November 2, 2018 21:40
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 shaun-sweet/32aa761d2fa0f96b470e062a6c94e9e3 to your computer and use it in GitHub Desktop.
Save shaun-sweet/32aa761d2fa0f96b470e062a6c94e9e3 to your computer and use it in GitHub Desktop.
Auto Hotkey app launcher/focuser
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; SEE https://autohotkey.com/docs/misc/Remap.htm for hotkey mappings
; This are examples of how to leverage the auto hotkey function that launches/focuses the application.
; The first argument is the location to the executable to launch the application. Some applications have "launchers" so to speak
; so the executable to launch and the process that runs from that aren't the same name.
; Check your task manager to find the name of the process can help get the focusing correct.
!e::ToggleApp("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "chrome.exe")
!i::ToggleApp("C:\Program Files (x86)\CMDer\Cmder.exe", "ConEmu64.exe")
!f::ToggleApp("C:\Users\sweet\AppData\Local\wavebox\app-4.4.0/wavebox.exe", "wavebox.exe")
!d::ToggleApp("C:\Users\sweet\AppData\Local\Discord\app-0.0.301/discord.exe", "discord.exe")
!a::ToggleApp("C:\Users\ssweet\AppData\Local\Programs\Microsoft VS Code\Code.exe", "Code.exe")
!k::ToggleApp("C:\Users\sweet\AppData\Local\gitkraken\app-3.4.1\gitkraken.exe", "gitkraken.exe")
ToggleApp(location, exe) {
If ProcessExist(exe)
WinActivate, ahk_exe %exe%
Else {
Run, %location%
}
}
ProcessExist(Name){
Process,Exist,%Name%
return Errorlevel
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment