-
-
Save Kirill/53423b3ce1bc7da011fd8ecc78b7e163 to your computer and use it in GitHub Desktop.
Autohotkey script. Run/Show/Hide Windows Terminal on top of the screen by F1 hotkey.
This file contains 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 | |
#SingleInstance force | |
SetWinDelay, -1 | |
DetectHiddenWindows, on | |
Menu, Tray, NoStandard | |
; Menu, Tray, Icon, wt-tilda.ico | |
Menu, Tray, Add, Exit, Exit | |
last_active_id := "" | |
shell_class := "ahk_class Shell_TrayWnd" | |
wt_class := "ahk_class CASCADIA_HOSTING_WINDOW_CLASS" | |
wt_exe := "wt.exe" | |
wt_id := "" | |
; hide/show on F1 | |
F1:: | |
Volume_Mute:: | |
If WinExist(wt_class) { | |
WinGet, wt_id, ID, %wt_class% | |
toggle() | |
} else { | |
init() | |
} | |
return | |
Exit: | |
ExitApp | |
; methods | |
showConsole() { | |
global | |
WinMove, ahk_id %wt_id%,, 0, 0, A_ScreenWidth, | |
WinActivate ahk_id %wt_id% | |
WinShow ahk_id %wt_id% | |
} | |
toggle() { | |
global | |
If WinActive("ahk_id " . wt_id) { | |
; last active window is console | |
If (wt_id = last_active_id) { | |
WinGet, last_active_id, ID, %shell_class% | |
} | |
WinActivate ahk_id %last_active_id% | |
WinHide ahk_id %wt_id% | |
} else { | |
; update last active window | |
WinGet, last_active_id, ID, A | |
showConsole() | |
} | |
} | |
init() { | |
global | |
WinGet, last_active_id, ID, A | |
Run %wt_exe% | |
WinWait %wt_class% | |
WinGet, wt_id, ID, %wt_class% | |
WinHide ahk_id %wt_id% | |
WinSet, Style, -0x00C00000, ahk_id %wt_id% ; WS_CAPTION - no border and title | |
WinSet, Style, -0x00040000, ahk_id %wt_id% ; WS_SIZEBOX - no resize | |
WinSet, ExStyle, +0x00000080, ahk_id %wt_id% ; WS_EX_TOOLWINDOW | |
WinSet, ExStyle, +0x00000100, ahk_id %wt_id% ; WS_EX_OVERLAPPEDWINDOW | |
showConsole() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment