Jump to content

WinWait and WinWaitActive Title Definition Not Working


AnAlien
 Share

Go to solution Solved by JohnReilly54,

Recommended Posts

Hi guys, I'm new to AutoIt and from what I've read in the help file, the two functions: WinWait and WinWaitActivate WinWaitActive aren't working as described. 

Both of the functions link to page: https://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm

Which explains how AutoIt has 3 Windows Matching Modes: Partial Title, Substring, and Exact Match. 

Substring mode doesn't seem to be working for the two functions above. Can someone confirm this? 

I used the AutoIt Script Recorder to record mouse and keyboard actions and it recorded window title. After I changed the file name, the window title no longer matched. 

For example, before when I recorded it, the title was: "Filename - Program Name". 

Once I changed file name, exact match didn't work any more so I changed the title to only include "Program Name" so it would work for all windows in that program regardless of filename. The two functions however are not picking up the substring title and keep the script paused (because they can't detect the right window). 

Edited by AnAlien
Link to comment
Share on other sites

So for a window of title "Untitled - Notepad", like you said: 

WinWait("Untitled")

works, but this doesn't:

WinWait("Notepad")

The Help File Says:

 

Mode 2

Matches any substring in the title.

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

e.g.

WinWait("Notepad")

 

 

...window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Notepad", "pad", etc.

 

Green works and red doesn't.

Edit: Sorry for the wrong function name. I meant:

WinWaitActive()

not WinWaitActivate(), which is a method created by the recorder. Can a mod change the title of the thread to the appropriate function, please?

Link to the method in help file: https://www.autoitscript.com/autoit3/docs/functions/WinWaitActive.htm

This method, like WinWait() accepts a string for the title. In the parameters table for title, you'll see the same link to "See title special definition" which is in WinWait's page as well.

Edited by AnAlien
Link to comment
Share on other sites

  • Solution

If you go to https://www.autoitscript.com/autoit3/docs/functions/AutoItSetOption.htm#WinTitleMatchMode you will see that the default value for WinTitleMatchMode is 1 not 2. 

 

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

 

This is probably what is causing you to have the issue.  At the top of the script you need to add

Opt ("WinTitleMatchMode", 2)

to get it to use that option.

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...