Last active
April 30, 2025 03:51
-
-
Save ianlini/e52c43ceb2a13e2f96c8931ee7dd7fda to your computer and use it in GitHub Desktop.
AutoHotkey script for supporting Quake style for Windows Terminal (alt+1). Also support "always on top" and "transparent window".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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. | |
SetBatchLines, -1 | |
Process, Priority,, High | |
Opacity := 200 ; [0, 255] or off | |
Height := 0.4 ; [0., 1.] | |
; Toggle windows terminal using Alt+1 | |
!1::ToggleTerminal() | |
ShowAndPositionTerminal(WinTitle) | |
{ | |
global Height | |
WinShow, %WinTitle% | |
WinActivate, %WinTitle% | |
WinGetPos, CurX, CurY, CurWidth, CurHeight, %WinTitle% | |
if (CurHeight != A_ScreenHeight) | |
{ | |
WinMove, %WinTitle%,, -9, -14, A_ScreenWidth + 18, A_ScreenHeight * Height | |
} | |
} | |
InitTerminal() | |
{ | |
global Opacity | |
; MsgBox, Iinitialize Windows Terminal | |
WinClassTitle := "ahk_class CASCADIA_HOSTING_WINDOW_CLASS" | |
Hwnd := WinExist(WinClassTitle) | |
if !Hwnd | |
{ | |
; Run new Windows Terminal | |
Run "wt" | |
WinWait, %WinClassTitle%,, 5 | |
if ErrorLevel | |
{ | |
MsgBox, Timeout waiting for wt!! | |
Return | |
} | |
Hwnd := WinExist(WinClassTitle) | |
} | |
WinIdTitle := "ahk_id " Hwnd | |
Winset, AlwaysOnTop, On, %WinIdTitle% | |
WinSet, Transparent, %Opacity%, %WinIdTitle% | |
WinHide, %WinIdTitle% | |
Return WinIdTitle | |
} | |
ToggleTerminal() | |
{ | |
static WinIdTitle := "" | |
DetectHiddenWindows, On | |
if !WinExist(WinIdTitle) | |
{ | |
; Iinitialization | |
WinIdTitle := InitTerminal() | |
} | |
DetectHiddenWindows, Off | |
if WinExist(WinIdTitle) | |
{ | |
; The window is not hidden, so hide the window | |
; MsgBox, Hide the window | |
WinHide, %WinIdTitle% | |
WinGetActiveTitle, ActiveTitle | |
if !ActiveTitle | |
{ | |
; Activate last focused window | |
; Use {Blind} to avoid releasing Alt if user already pressed down Alt | |
Send {Blind}!{Esc} | |
} | |
} | |
else | |
{ | |
; The window is hidden, so show the window | |
ShowAndPositionTerminal(WinIdTitle) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment