-
-
Save Darkle/faad40b6636fd51510a2511e7b8a08ca to your computer and use it in GitHub Desktop.
AHK Script for Calling Out Windows Terminal
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
; The path to the Windows Terminal exe file. | |
WtPath = "%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe" | |
^space::ToggleTerminal() | |
ShowAndPositionTerminal() | |
{ | |
ScreenX := GetScreenLeft() | |
ScreenY := GetScreenBottom() | |
ScreenWidth := GetScreenWidth() | |
global VRatio | |
WinShow ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
WinActivate ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
WinMove, ahk_class CASCADIA_HOSTING_WINDOW_CLASS,, ScreenX-5, ScreenY-550, ScreenWidth+10, 550, | |
} | |
ToggleTerminal() | |
{ | |
WinMatcher := "ahk_class CASCADIA_HOSTING_WINDOW_CLASS" | |
DetectHiddenWindows, On | |
if WinExist(WinMatcher) | |
; Window Exists | |
{ | |
DetectHiddenWindows, Off | |
; Check if its hidden | |
if !WinExist(WinMatcher) || !WinActive(WinMatcher) | |
{ | |
ShowAndPositionTerminal() | |
} | |
else if WinExist(WinMatcher) | |
{ | |
; Script sees it without detecting hidden windows, so.. | |
WinHide ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
Send !{Esc} | |
} | |
} | |
else | |
{ | |
global WtPath | |
Run %WtPath% | |
Sleep, 1000 | |
ShowAndPositionTerminal() | |
} | |
} | |
GetScreenBottom() { | |
WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,, | |
return TY | |
} | |
GetScreenLeft() { | |
WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,, | |
return 0 | |
} | |
GetScreenWidth() { | |
WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,, | |
return A_ScreenWidth | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info: microsoft/terminal#653