Problem with switching between identical windows.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
KilliK
Posts: 255
Joined: 10 Mar 2016, 21:19

Problem with switching between identical windows.

16 Jan 2019, 21:15

Hello.

I am using this excellent WinTrigger script from the user MasterFocus, so that a code is executed whenever a specific window becomes active.

https://autohotkey.com/board/topic/5905 ... f-windows/

Code: Select all

ProgWinTitle1 = WinTitle
WinTrigger1 = Active

CheckPeriod = 1000
SetTimer, LabelCheckTrigger, %CheckPeriod%
Return
 
LabelCheckTrigger:
  While ( ProgWinTitle%A_Index% != "" && WinTrigger := WinTrigger%A_Index% )
    if ( !ProgRunning%A_Index% != !Win%WinTrigger%( ProgWinTitle := ProgWinTitle%A_Index% ) )
      GoSubSafe( "LabelTriggerO" ( (ProgRunning%A_Index% := !ProgRunning%A_Index%) ? "n" : "ff" ) A_Index )
Return
But I came across a problem. The script is not triggered when I switch between two windows with the exact same WinTitle (same title,class,process), because WinTrigger still thinks that my previous window is still active, although I switched to a new one.

Because of this, now I need some extra method so that AHK understands when I have switched to a new window, while the new and the old window have the same WinTitle.

Any idea how I can fix this? Other than this special case, the WinTrigger script works fine and I recommend it.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Problem with switching between identical windows.

19 Jan 2019, 14:03

Check the hWnd.
WinGet, hWnd, ID, % WinTitle
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ccqcl, Descolada and 354 guests