Created
February 15, 2020 17:41
-
-
Save andrewgodwin/89920ee02501ab12d09b02500897066c to your computer and use it in GitHub Desktop.
AutoHotkey script for making Windows Terminal appear/disappear with a single keypress
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 ; 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. | |
F12::ToggleTerminal() | |
ShowAndPositionTerminal() | |
{ | |
WinShow ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
WinActivate ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
SysGet, WorkArea, MonitorWorkArea | |
TerminalWidth := A_ScreenWidth * 0.9 | |
if (A_ScreenWidth / A_ScreenHeight) > 1.5 { | |
TerminalWidth := A_ScreenWidth * 0.6 | |
} | |
WinMove, ahk_class CASCADIA_HOSTING_WINDOW_CLASS,, (A_ScreenWidth - TerminalWidth) / 2, WorkAreaTop - 2, TerminalWidth, A_ScreenHeight * 0.5, | |
} | |
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 | |
{ | |
Run "c:\Users\Andrew\AppData\Local\Microsoft\WindowsApps\wt.exe" | |
Sleep, 1000 | |
ShowAndPositionTerminal() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there! i'm using the same script but wt.exe is not opening at all. not even if i open it from the file explorer. Anyone with this issue?
If i open the terminal app from it's shortcut it opens without any problem