Skip to content

Instantly share code, notes, and snippets.

@sharunkumar
Last active June 17, 2020 19:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sharunkumar/af7ba56e3cce8238ae9c986c619e8d1c to your computer and use it in GitHub Desktop.
Save sharunkumar/af7ba56e3cce8238ae9c986c619e8d1c to your computer and use it in GitHub Desktop.
Autohotkey script for hooking win+` to open and toggle to the new windows terminal. Terminal will be spawned if it isn't opened already.
#SingleInstance, force
global PreviousActiveWindow
; Requires windows terminal preview: https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701
#`::
DetectHiddenWindows, On
if (WinExist("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) {
if(WinActive("ahk_class CASCADIA_HOSTING_WINDOW_CLASS")) {
WinActivate, ahk_id %PreviousActiveWindow%
} else {
WinGet, PreviousActiveWindow, , A ; 'A' for currently active window
WinActivate, ahk_class CASCADIA_HOSTING_WINDOW_CLASS
}
} else {
TerminalLink = %localappdata%\Microsoft\WindowsApps\wt.exe
if FileExist(TerminalLink) {
WinGet, PreviousActiveWindow, , A ; 'A' for currently active window
Run, %TerminalLink%
} else {
MsgBox, Windows Terminal not installed
}
}
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment