Wait untill neither of specified windows are active using regex

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
califauna
Posts: 6
Joined: 31 May 2016, 19:41

Wait untill neither of specified windows are active using regex

01 Jun 2020, 11:54

This works...

Code: Select all

SetTitleMatchMode, RegEx
WinWaitActive, ahk_class (?:Ableton Live Window Class|bitwig)
But later in the same script, this doesn't work...

Code: Select all

WinWaitNotActive, ahk_class (?=Ableton Live Window Class)(?=bitwig)
It proceeds with the script, even when one of the windows is still active.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: Wait untill neither of specified windows are active using regex

01 Jun 2020, 14:14

You have two positive look-aheads meaning it will match when both are found (and not sure look-aheads are what you want). Aren't you just trying to allow one or the other like this? :

Code: Select all

WinWaitNotActive, ahk_class (Ableton Live Window Class|bitwig)
califauna
Posts: 6
Joined: 31 May 2016, 19:41

Re: Wait untill neither of specified windows are active using regex

01 Jun 2020, 15:37

boiler wrote:
01 Jun 2020, 14:14
You have two positive look-aheads meaning it will match when both are found (and not sure look-aheads are what you want). Aren't you just trying to allow one or the other like this? :

Code: Select all

WinWaitNotActive, ahk_class (Ableton Live Window Class|bitwig)
I'm trying for WinWaitNotactive to return true and proceed with the script when neither Ableton nor Bitwig are the active window (I mean, when the active window is something other than Ableton or Bitwig). Doesn't matter which ahk_class is the active window, just as long as it's not one of those to.

I've tried this as well:

Code: Select all

WinWaitNotActive, ahk_class (?:Ableton Live Window Class&bitwig)
califauna
Posts: 6
Joined: 31 May 2016, 19:41

Re: Wait untill neither of specified windows are active using regex

01 Jun 2020, 19:37

Using your code it works.

I added

Code: Select all

?:
is it avoids saving the group Ableton 'Live Window Class|bitwig' into memory apparently:

Code: Select all

WinWaitNotActive, ahk_class (?:Ableton Live Window Class|bitwig)
Somewhere down the line a logical NOR is getting created right? But where? The bar means 'bitwise-or' right, so, when I look at your correct code I see In pseudocode):

"Wait until the active window is not the following : EITHER ahk_class 'Ableton Live Window Class' OR ahk_class 'bitwig'".

But that condition seems to me to be met when EITHER of the two programs are not the active window, not NEITHER.

What am I misunderstanding here?
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: Wait untill neither of specified windows are active using regex

01 Jun 2020, 19:55

I suppose this is a side point, but the vertical bar character (|) is not a bitwise "or" in RegEx. It doesn't make sense to refer to bits when referring to regular expressions because it deals in characters. It means that either group of characters is a match.

More to the point, in this particular case, you're right that the expression itself means it will match:
ahk_class Ableton Live Window Class or ahk_class bitwig

So now you say WinWaitNotActive with that expression. So it will wait until that expression does not match any window. That expression will match a window if either of those windows are active, so it will keep waiting until neither of those are active.
califauna
Posts: 6
Joined: 31 May 2016, 19:41

Re: Wait untill neither of specified windows are active using regex

02 Jun 2020, 06:03

Thanks.

As I read the code its still not intuitive for me why that waits until neither are the active window, rather than EITHER of the two, but I'll play with some other scenarios and try to get used to it.
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: Wait untill neither of specified windows are active using regex

02 Jun 2020, 06:09

Reread what I said. It makes sense if you follow it logically. It is waiting for no windows that match that expression to be active. If you are waiting for no match, that means any window that matches cannot be active or else it will keep waiting. Either of those windows will cause a match. It makes perfect logical sense.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], bobstoner289, Chunjee, macromint, peter_ahk and 341 guests