Code: Select all
; #IfWinExist Main@thinkorswim
!+w:: ; ALT+SHIFT+w
SetTitleMatchMode, 1 ;
If WinActive(wTitle := "Main@thinkorswim [build ")
WinMinimize
Else WinActivate, %wTitle%
Return
; #IfWinExist
In virtual desktop #1, when I use the hotkey, the virtual desktop changes to another virtual desktop and the thinkorswim Main window (I'll refer to this as TOS Main) is the active window. If I start in in virtual desktop #1 and click on TOS Main, then press the hotkey, TOS Main gets minimized (good!). But if press the hotkey again, it switches to another virtual desktop and makes TOS Main instance in that desktop active. Once the script has switched me to another desktop, then the hotkey toggles the TOS Main window in that desktop as expected.
So the script can correctly identify the window, but not the desired instance of the window. Is there a way to restrict the script to a single virtual desktop (either the current virtual desktop, or a specified number virtual desktop)?