joelkolb Posted October 25, 2016 Share Posted October 25, 2016 I wrote a script that will wait for any window with a title that matches any one out of a set of titles and when such a window appears it will automatically close. See below: Opt("WinTitleMatchMode", 3) $WindTitles = "[REGEXPTITLE:(?i)(First title|Second title|Third title)]" While True WinWait($WindTitles) If WinExists($WindTitles) Then WinClose($WindTitles) EndIf WEnd Notice I put Opt("WinTitleMatchMode", 3) at the beginning because I specifically want only exact matches of the titles provided. There are instances where windows will open that may contain part of one of the titles provided but those must not be closed. However it seems that when I use REGEXPTITLE it will match even partial matches and even different cases. For example if a window had a title "Blah blah third title blah" that window would be closed by my script because it has third title in it. As far as I know, using REGEXPTITLE is the only way to do something like WinWait(First title Or Second title Or Third title) which is what I need, but it does not appear to perform exact matches. I've tested without using REGEXPTITLE and just a single one of the titles I need to match (e.g. WinWait(First title)) and it works as expected, only exact matches including case. So it seems like it's an issue with REGEXPTITLE not performing exact matches. Does anyone know a way to make REGEXPTITLE perform exact matches, or some other way to get an exact match for any one out of a set of window titles that would accomplish what I'm trying to do in the script above? Thanks Link to comment Share on other sites More sharing options...
joelkolb Posted October 25, 2016 Author Share Posted October 25, 2016 OK, so I feel pretty silly now. I figured out that the (?i) after REGEXPTITLE: instructs it to perform a caseless match. I'm still a bit concerned that things aren't working all the way though. Regardless of case it was still matching a substring and not the exact title. Is there a way to account for that? Link to comment Share on other sites More sharing options...
jguinch Posted October 25, 2016 Share Posted October 25, 2016 Use the anchors ^ (start of the text) and $ (end of text): "[REGEXPTITLE:(?i)^(First title|Second title|Third title)$]" Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
joelkolb Posted October 25, 2016 Author Share Posted October 25, 2016 @jguinch, thanks a million. Between adding ^ at the beginning and $ at the end as you recommended and removing the (?i) it looks like I'm getting perfect matches. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now