Created
April 3, 2020 19:08
-
-
Save zakius/b945969a8a4a6b333237650504cab3bf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;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