The UseWindowRegEx function specifies the window to which subsequent keyboard, mouse and menu actions are directed, using Regular Expressions to specify the window title part of the window name.
Used to bring to foreground/front the specified window so that it may receive keystrokes, mouse clicks and other interactive actions. UseWindowRegEx extends the UseWindow partial match and can trigger on a sub-string within the window title. Regular expressions are text patterns that are used for window title matching.
ret=UseWindowRegEx(<window_name> [, Noactivate])
<window_name>, string, window name of the window to bring to foreground. A Regular expression can be used to specify the title part of <window_name>, for example if in "NOTEPAD.EXE|Edit|20.txt - Notepad" 20 is a day number which changes every day,
UseWindowRegEx("NOTEPAD.EXE|Edit|[0-9][0-9].* - Notepad")
triggers on a window title whatever day number in it.
Noactivate, optional keyword. If used, <window_name> does not take the focus.
ret, optional numeric return value. If the window has been found within 30 seconds (this default value can be changed using #ActionTimeout), the function returns 0. If the function fails, the return value is a nonzero value (see Window Functions Error Codes).
During execution, if the target window is minimized, the UseWindowRegEx automatically restores it and activates it (unless NoActivate keyword is used).
'We list below the most common Regular expressions
'Keys have to be sent to the notepad window whatever character is after Doc
UseWindowRegEx("NOTEPAD.EXE|Edit|Doc. - Notepad|1")
'Triggers for any window Doca, Docb, ..., Doc0, Doc1, ....
'Single character in a list
'Keys have to be sent to the notepad window if, after Doc, the year is 2007, 2008 or 2009
UseWindowRegEx("NOTEPAD.EXE|Edit|Doc200 - Notepad|1")
'Triggers for any window Doc2007, Doc2008, or Doc2009
'Single character NOT in a list
'Keys have to be sent to the notepad window if, after Doc, the year is NOT 2005, 2006 or 2007
UseWindowRegEx("NOTEPAD.EXE|Edit|Doc200[^567] - Notepad|1")
'Triggers for any window Doc2000, Doc2001, Doc2002, Doc2003, Doc2004, Doc2008, Doc2009 and Doc200a, Doc200b, ...
'Single character within a range
'Keys have to be sent to the notepad window if, after Doc, it can be any year in the 1990s
UseWindowRegEx("NOTEPAD.EXE|Edit|Doc199[0-9] - Notepad|1")
'Triggers for any window Doc1990, Doc1991,..., Doc1999