-
Notifications
You must be signed in to change notification settings - Fork 0
/
hotkey.ahk
34 lines (30 loc) · 1019 Bytes
/
hotkey.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
; Credits to https://blog.danskingdom.com/Bring-up-the-Windows-Terminal-in-a-keystroke/
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, explorer.exe shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App
}
}
; Hotkey to use Ctrl+` (tilde button) to launch/restore the Windows Terminal.
^`::SwitchToWindowsTerminal()