Jump to content

Opt("WinTitleMatchMode", 2) & REGEXPTITLE


Recommended Posts

hi,

how to match a word only in single characters?

like when i want to match 'News' using Opt("WinTitleMatchMode", 2) then it also matches with the following.

CnnNews

NewsFuse

ZeeNews

but i want that it should only match if single word exists in window like

this is a good News

today's news is very bad.

?

Link to comment
Share on other sites

You are rhave to use REGEXPTITLE. Opt is not required.

$GUI = GUICreate("News")
MsgBox(0, 'News', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","TestNews")
MsgBox(0, 'TestNews', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","Test News")
MsgBox(0, 'Test News', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","NewsTest")
MsgBox(0, 'NewsTest', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","News Test")
MsgBox(0, 'News Test', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","news")
MsgBox(0, 'news', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","NEWS")
MsgBox(0, 'NEWS', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","NEWS")
MsgBox(0, 'NEWS', "CaseSen=False" & @CRLF & _WinExistsFullWord("News",False))

; Prog@ndy
Func _WinExistsFullWord($Word,$CaseSen = True)
    If Not $CaseSen Then 
        $CaseSen = "(?i)"
    Else
        $CaseSen =""
    EndIf
    Return WinExists("[REGEXPTITLE:"&$CaseSen&"(\A|\s)\Q"&$Word&"\E(\s|\Z)]")
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

You are rhave to use REGEXPTITLE. Opt is not required.

$GUI = GUICreate("News")
MsgBox(0, 'News', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","TestNews")
MsgBox(0, 'TestNews', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","Test News")
MsgBox(0, 'Test News', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","NewsTest")
MsgBox(0, 'NewsTest', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","News Test")
MsgBox(0, 'News Test', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","news")
MsgBox(0, 'news', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","NEWS")
MsgBox(0, 'NEWS', _WinExistsFullWord("News"))

WinSetTitle($GUI,"","NEWS")
MsgBox(0, 'NEWS', "CaseSen=False" & @CRLF & _WinExistsFullWord("News",False))

; Prog@ndy
Func _WinExistsFullWord($Word,$CaseSen = True)
    If Not $CaseSen Then 
        $CaseSen = "(?i)"
    Else
        $CaseSen =""
    EndIf
    Return WinExists("[REGEXPTITLE:"&$CaseSen&"(\A|\s)\Q"&$Word&"\E(\s|\Z)]")
EndFunc
thanks for the code!
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...