Window Titles and Text (Advanced)

AutoIt X

Window Titles and Text (Advanced)

AutoIt operates in one of three "Window matching" modes. The modes are set with the AutoItSetOption function using the WinTitleMatchMode option.

 

Mode 1 (default)

Matches partial titles from the start.

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

eg.

    oAutoIt.WinWait "Untitled"

 

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.

eg.

    oAutoIt.WinWait "Notepad"

 

Mode 3

Exact title match.

In this mode a window titled Untitled - Notepad would only be matched by "Untitled - Notepad"

 

Mode 4 (Kept for backward compatibility)

Advanced mode

Must be replaced with Advanced Window Descriptions which does not need any mode to be set.

 

Mode -1 to -4

Force lower case match according to other type of match.

Advanced Window Descriptions

A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:

  • TITLE - Window title
  • CLASS - The internal window classname
  • REGEXPTITLE - Window title using a regular expression
  • REGEXPCLASS - Window classname using a regular expression
  • LAST - Last window used in a previous AutoIt command
  • ACTIVE - Currently active window
  • X \ Y \ W \ H - The position and size of a window
  • INSTANCE - The 1-based instance when all given properties match
  • HANDLE - The handle address as returned by a method like WinGetHandle

One or more properties are used in the title parameter of a window command in the format:

[PROPERTY1:Value1; PROPERTY2:Value2]

Note : if a Value must contain a ";" it must be doubled.

 

e.g. Wait a window of classname "Notepad"

oAutoIt.WinWaitActive "[CLASS:Notepad]", ""

 

e.g. Close the currently active window

oAutoIt.WinClose "[ACTIVE]", ""

 

e.g. Wait for the 2nd instance of a window with title "My Window" and classname "My Class"

oAutoIt.WinWaitActive "[TITLE:My Window; CLASS:My Class; INSTANCE:2]", ""

 

Note : if a Value must contain a ";" it must be doubled.