Sign in to follow this  
Followers 0
packrat

Title matching: titlestring vs TITLE vs REGEXPTITLE

3 posts in this topic

Two questions:

(1) Suppose that a window title is the string "aaa bbb ccc", but the "ccc" part can vary from window to window. When using a command such as WinWaitActive($Title...), which of the following three possibilities will match the varying window title "aaa bbb ccc"?

a -- $Title = "aaa bbb"

b -- $Title = "[TITLE:aaa bbb]"

c -- $Title = "[REGEXPTITLE:^aaa bbb]"

Essentially, what I'm trying to figure out (and which does not seem indicated in the documentation) is when window commands will match the initial portion (substring) of a window title. In other words, how much of a window title is it absolutely necessary to specify when doing matching using the above approaches? I'm seeking the shortest and easiest method (the minimalist approach). For example, is method "a" sufficient, or do I have to use the entire enchilada in method "c"? I think method "a" used to work for initial substrings, but I don't know if the new methods "b" and "c" that we're supposed to use make that not the case any more.

Since Mode 4 is no longer required (see next question below), does the answer to the above (at least for methods "b" and "c") depend on which mode (or none) is used?

(2) Up until now I've generally used Advanced Window Matching Mode 4 as a matter of course. However, the most recent versions of AutoIt state, "Must be replaced with Advanced Window Descriptions which does not need any mode to be set." Does this mean that, when using Advanced Window Descriptions, no matching mode should be specified or that one of modes 1 to 3 can (should?) be used in place of mode 4? (I realize that Mode 4 is permitted, but not required, to be specified for backward compatibility.)

Looking for clarification and thanking everybody in advance,

Harvey

Share this post


Link to post
Share on other sites



Opt("WinTitleMatchMode", 2) ; Match any substring in the title.

In this mode a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Notepad", "pad", etc.

Share this post


Link to post
Share on other sites

Two questions:

(1) Suppose that a window title is the string "aaa bbb ccc", but the "ccc" part can vary from window to window. When using a command such as WinWaitActive($Title...), which of the following three possibilities will match the varying window title "aaa bbb ccc"?

a -- $Title = "aaa bbb"

b -- $Title = "[TITLE:aaa bbb]"

c -- $Title = "[REGEXPTITLE:^aaa bbb]"

Essentially, what I'm trying to figure out (and which does not seem indicated in the documentation) is when window commands will match the initial portion (substring) of a window title. In other words, how much of a window title is it absolutely necessary to specify when doing matching using the above approaches? I'm seeking the shortest and easiest method (the minimalist approach). For example, is method "a" sufficient, or do I have to use the entire enchilada in method "c"? I think method "a" used to work for initial substrings, but I don't know if the new methods "b" and "c" that we're supposed to use make that not the case any more.

Since Mode 4 is no longer required (see next question below), does the answer to the above (at least for methods "b" and "c") depend on which mode (or none) is used?

(2) Up until now I've generally used Advanced Window Matching Mode 4 as a matter of course. However, the most recent versions of AutoIt state, "Must be replaced with Advanced Window Descriptions which does not need any mode to be set." Does this mean that, when using Advanced Window Descriptions, no matching mode should be specified or that one of modes 1 to 3 can (should?) be used in place of mode 4? (I realize that Mode 4 is permitted, but not required, to be specified for backward compatibility.)

Looking for clarification and thanking everybody in advance,

Harvey

Perhaps you could have just tried some testing...? :mellow:

$iPID = Run("notepad.exe")
WinWait("[TITLE:Untitled -]")
$hWIN = WinGetHandle("[TITLE:Untitled -]")
WinSetTitle($hWIN, "", "aaa bbb ccc")
; Begining of string
ConsoleWrite('WinExists("aaa bbb") = ' & WinExists("aaa bbb") & @LF)
ConsoleWrite('WinExists("[TITLE:aaa bbb]") = ' & WinExists("[TITLE:aaa bbb]") & @LF)
ConsoleWrite('WinExists("[REGEXPTITLE:aaa bbb]") = ' & WinExists("[REGEXPTITLE:aaa bbb]") & @LF)
; Middle of string
ConsoleWrite('WinExists("bbb") = ' & WinExists("bbb") & @LF)
ConsoleWrite('WinExists("[TITLE:bbb]") = ' & WinExists("[TITLE:bbb]") & @LF)
ConsoleWrite('WinExists("[REGEXPTITLE:.+bbb.+]") = ' & WinExists("[REGEXPTITLE:.+bbb.+]") & @LF)
WinClose($hWIN)

:(


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
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
Sign in to follow this  
Followers 0