Skip to content

Instantly share code, notes, and snippets.

@zakius
Created April 3, 2020 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zakius/b945969a8a4a6b333237650504cab3bf to your computer and use it in GitHub Desktop.
Save zakius/b945969a8a4a6b333237650504cab3bf to your computer and use it in GitHub Desktop.
;OPTIMIZATIONS START
;#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
;OPTIMIZATIONS END
; The path to the Windows Terminal exe file.
WtPath = "%LOCALAPPDATA%\Programs\Messenger\Messenger.exe"
WinMatcher := "Messenger: ahk_exe Messenger.exe"
PreviousActive = 0
ToggleTerminal()
!Q::ToggleTerminal()
ShowAndPositionTerminal()
{
global WinMatcher
global PreviousActive
WinGet, PreviousActive ,, A ; <-- need to identify window A = acitive
WinShow % WinMatcher
WinMaximize % WinMatcher
WinActivate % WinMatcher
}
ToggleTerminal()
{
global WinMatcher
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..
global PreviousActive
WinHide % WinMatcher
WinActivate ahk_id %PreviousActive%
}
}
else
{
global PreviousActive
WinGet, PreviousActive ,, A ; <-- need to identify window A = acitive
global WtPath
Run %WtPath%
Sleep, 1500
WinHide % WinMatcher
WinActivate ahk_id %PreviousActive%
;ShowAndPositionTerminal()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment