Skip to content

Instantly share code, notes, and snippets.

@Darkle
Forked from wizcas/winterm-callout.ahk
Last active January 13, 2020 05:32
Show Gist options
  • Save Darkle/faad40b6636fd51510a2511e7b8a08ca to your computer and use it in GitHub Desktop.
Save Darkle/faad40b6636fd51510a2511e7b8a08ca to your computer and use it in GitHub Desktop.
AHK Script for Calling Out Windows Terminal
; 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
}
@Darkle
Copy link
Author

Darkle commented Jan 13, 2020

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