SetTitleMatchMode

Sets the matching behavior of the WinTitle parameter in commands such as WinWait.

SetTitleMatchMode, MatchMode
SetTitleMatchMode, Fast|Slow

 

Parameters

MatchMode

One of the following numbers:

1: A window's title must start with the specified WinTitle to be a match.
2: A window's title can contain WinTitle anywhere inside it to be a match.
3: A window's title must exactly match WinTitle to be a match.

The above mode also affects ExcludeTitle in the same way. For example, mode 3 requires that a window's title exactly match ExcludeTitle for that window to be excluded.

Note that WinTitle, WinText, ExcludeTitle and ExcludeText are always case sensitive.

Fast|Slow

Fast: This is the default behavior. Performance may be substantially better than Slow, but certain WinText elements for some types of windows may not be "seen" by the various window commands.

Slow: Can be much slower, but all possible WinText is retrieved from every window as a windowing command searches through them for a match. Window Spy reveals which parts of a Window's text (if any) require the slow mode.

 

Remarks

This command affects the behavior of all windowing commands, e.g. IfWinExist and WinActivate.

If unspecified, TitleMatchMode defaults to 1 and fast.

Generally, the slow mode should only be used if the target window cannot be uniquely identified by its title and fast-mode text. This is because the slow mode can be extremely slow if there are any application windows that are busy or "not responding".

The customized version of Window Spy distributed with AutoHotkey reports slow text in a separate section so that its easy to determine whether the slow mode is needed.

If you wish to change both attributes, run the command twice as in this example:
SetTitleMatchMode, 2
SetTitleMatchMode, slow

The built-in variables A_TitleMatchMode and A_TitleMatchModeSpeed contain the current settings.

Title and text matching are always case sensitive regardless of this setting.

Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).

 

Related

SetWinDelay, IfWinExist, WinActivate

 

Example

SetTitleMatchMode, 2
SetTitleMatchMode, slow