Skip to content

Instantly share code, notes, and snippets.

@rbreaves
Created January 16, 2022 19:45
Show Gist options
  • Save rbreaves/eb7c989ecf71440e31d1f159d2a4619d to your computer and use it in GitHub Desktop.
Save rbreaves/eb7c989ecf71440e31d1f159d2a4619d to your computer and use it in GitHub Desktop.
QuakeTerminal & hide all other Apps while using VSCode
#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.
SetTimer, HideTerminal, 1000 ;
return
WinMatcher := "ahk_class CASCADIA_HOSTING_WINDOW_CLASS"
HideTerminal:
If WinActive("ahk_exe Code.exe")
{
WinGet, AllWindows, List
loop %AllWindows% {
WinGet, Active_Process, ProcessName, % " ahk_id " AllWindows%A_Index%
WinGetTitle, WinTitle, % " ahk_id " AllWindows%A_Index%
WinGet, State, MinMax, % " ahk_id " AllWindows%A_Index%
if ((State != -1 && Active_Process != "Code.exe" && Active_Process != "Explorer.EXE" ) || ( State != -1 && Active_Process == "Explorer.EXE" && WinTitle != "Program Manager" && WinTitle != "" ) ){
; && Active_Process != "Explorer.EXE"
WinMinimize, % "ahk_id " AllWindows%A_Index%
; MsgBox, Process: %Active_Process% %WinTitle%
}
}
}
return
!`::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.8
}
WinMove, ahk_class CASCADIA_HOSTING_WINDOW_CLASS,, (A_ScreenWidth - TerminalWidth) / 2, WorkAreaTop - 2, TerminalWidth,
}
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\%A_UserName%\AppData\Local\Microsoft\WindowsApps\wt.exe"
Sleep, 1000
ShowAndPositionTerminal()
}
}
@rbreaves
Copy link
Author

Helpful for my particular workflow, which involves 2 users & RDP user sessions with multiple monitors. Otherwise I would not minimize other apps while VSCode is in focus, same monitor or not. Also helps when combined with transparency VSCode plugin, can easily create a nice blur effect if that is desired & without any compositor in Linux or Windows or Mac.

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