Skip to content

Instantly share code, notes, and snippets.

@baflo
Last active December 17, 2020 08:16
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 baflo/a0ab2f1c8e8532d8eb95a99bd59e05ee to your computer and use it in GitHub Desktop.
Save baflo/a0ab2f1c8e8532d8eb95a99bd59e05ee to your computer and use it in GitHub Desktop.
AutoHotKey script: Toggles (minimizes or restores) windows an keyboard shortcut
#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.
ShowHideWindow(winTitle, winExe := "")
{
WinGet, targetWindowID, IDLast, %winTitle%
if ("%winExe%" != "") and (not WinExist(winTitle)) {
Run, "%winExe%"
}
else {
IfWinActive, ahk_id %targetWindowID%
WinMinimize, ahk_id %targetWindowID%
Else
WinActivate, ahk_id %targetWindowID%
}
}
^+y::
ShowHideWindow("ahk_exe Slack.exe")
Return
^+a::
ShowHideWindow("ahk_exe notion.exe", "C:\Users\fb\AppData\Local\Programs\Notion\Notion.exe")
Return
^+q::
ShowHideWindow("ahk_exe WindowsTerminal.exe", "wt.exe")
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment