#IfWinNotActive - how to define a Regex pattern?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

#IfWinNotActive - how to define a Regex pattern?

Post by m3user » 15 Aug 2023, 05:09

Hi, I'm trying to use Regex to define a group of windows in which the hotstring should not trigger.
The script below is not working, any idea what am I missing?

Code: Select all

SetTitleMatchMode, RegEx

#IfWinNotActive i)notepad|ahk_class Chrome_WidgetWin_1
::br::best regards
#IfWinActive
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: #IfWinNotActive - how to define a Regex pattern?

Post by mikeyww » 15 Aug 2023, 05:15

Hello,

A glance at the documentation may help this one.

SetTitleMatchMode:
RegEx [v1.0.45+]: Changes WinTitle, WinText, ExcludeTitle, and ExcludeText to accept regular expressions, e.g. WinActivate Untitled.*Notepad. RegEx also applies to ahk_class and ahk_exe, e.g. ahk_class IEFrame searches for any window whose class name contains IEFrame anywhere (this is because by default, regular expressions find a match anywhere in the target string). For WinTitle, each component is separate, e.g. in i)^untitled ahk_class i)^notepad$ ahk_pid %mypid%, i)^untitled and i)^notepad$ are separate regex patterns and %mypid% is always compared numerically (it is not a regex pattern). For WinText, each text element (i.e. each control's text) is matched against the RegEx separately, so it is not possible to have a match span more than one text element.
No RegEx needed here:

Code: Select all

#If !WinActive("ahk_exe notepad.exe") && !WinActive("ahk_class Chrome_WidgetWin_1")
Last edited by mikeyww on 15 Aug 2023, 05:21, edited 1 time in total.
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: #IfWinNotActive - how to define a Regex pattern?

Post by m3user » 15 Aug 2023, 05:20

Thanks!
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: #IfWinNotActive - how to define a Regex pattern?

Post by mikeyww » 15 Aug 2023, 05:21

You are welcome. I added a comment that no regex is needed, so you can use the default title match mode instead of changing it.
Post Reply

Return to “Ask for Help (v1)”