Skip to content

Instantly share code, notes, and snippets.

@lu0
Forked from andrewgodwin/QuakeTerminal.ahk
Last active March 10, 2023 07:25
Show Gist options
  • Save lu0/8f39b9193d08a74f9c51b98dff6bdc03 to your computer and use it in GitHub Desktop.
Save lu0/8f39b9193d08a74f9c51b98dff6bdc03 to your computer and use it in GitHub Desktop.
AutoHotkey script to hide/show a Windows Terminal using a keybinding
#NoTrayIcon
#SingleInstance Force
;
; This scripts toggles between states raised and hidden of a Windows Terminal,
; or opens a new one if not opened, using `Super + T` or `Super + Enter`
;
; Supports multiple workspaces or virtual desktops.
;
#T::
#Enter::
ToggleTerminal()
ToggleTerminal() {
matcher := "ahk_class CASCADIA_HOSTING_WINDOW_CLASS"
DetectHiddenWindows, On
if WinExist(matcher) {
if !WinActive(matcher) {
; Hide it first to alow raising it later on a different workspace
HideTerminal()
ShowTerminal()
} else if WinExist(matcher) {
HideTerminal()
}
} else {
OpenNewTerminal()
}
}
OpenNewTerminal() {
Run C:\Users\%A_UserName%\AppData\Local\Microsoft\WindowsApps\wt.exe
Sleep, 1000
ShowTerminal()
}
ShowTerminal() {
WinShow ahk_class CASCADIA_HOSTING_WINDOW_CLASS
WinActivate ahk_class CASCADIA_HOSTING_WINDOW_CLASS
}
HideTerminal() {
WinHide ahk_class CASCADIA_HOSTING_WINDOW_CLASS
}
@lu0
Copy link
Author

lu0 commented May 10, 2022

Updated to support workspaces (virtual desktops) as raised in #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment