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, a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc.
e.g.
@@SyntaxHighlighting@@ WinWait("Untitled") @@End@@
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.
@@SyntaxHighlighting@@ WinWait("Notepad") @@End@@
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
Replaced by Advanced Window Descriptions which work in any mode.
Mode -1 to -4
Case insensitive match according to the other type of match.
A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:
One or more properties are used in the title parameter of a window command in the format:
@@SyntaxHighlighting@@ [PROPERTY1 : Value1; PROPERTY2:Value2] @@End@@
Note : if a Value must contain a ";" it must be doubled.
e.g. Wait for a window with the classname "Notepad".
@@SyntaxHighlighting@@ WinWaitActive("[CLASS:Notepad]", "") @@End@@
e.g. Close the currently active window
@@SyntaxHighlighting@@ WinClose("[ACTIVE]", "") @@End@@
e.g. Wait for the 2nd instance of a window with title "My Window" and classname "My Class"
@@SyntaxHighlighting@@ WinWaitActive("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "") @@End@@
e.g. List windows matching Title defined by a regular expression
@@SyntaxHighlighting@@ WinList("[REGEXPTITLE:(?i)(.*SciTE.*|.*Internet Explorer.*)]") @@End@@The variant datatype in AutoIt natively supports window handles (HWNDs). A window handle is a special value that Windows assigns to windows each time they are created. When you have a handle you may use it in place of the title parameter in any of the function calls that use the title/text convention. The advantage of using window handles is that if you have multiple copies of an application open which have the same title/text then you can uniquely identify them using handles. When you use a window handle for the title parameter then the text parameter is completely ignored.
Various functions such as WinGetHandle, WinList and GUICreate return these handles. It is important to note that a window handle is not classed as a number or string - it is its own special type.
Note: Window handles will work no matter what WinTitleMatchMode is currently in use.
Example
@@SyntaxHighlighting@@ Local $hWnd = WinGetHandle("Untitled - Notepad", "") WinClose($hWnd) @@End@@