ctrx_find_window_by_name

Example

This function is available from version 2022 R1.

Searches all tracked windows for a specified window.

int ctrx_find_window_by_name( char *Caption, long Match );

CaptionCaption of the window to search for.
Match

The search option that defines the type of search. Possible values:

  • MATCH_Exact: Case-sensitive comparison.
  • MATCH_ExactNoCase: Case-insensitive comparison.
  • MATCH_Wildcard: The search string must either begin or end with a '*' character, which matches everything. The rest of the string is compared case sensitively.
  • MATCH_WildcardNoCase: The search string must either begin or end with a '*' character, which matches everything. The rest of the string is compared case insensitively.
  • MATCH_RegExp: The search string is a regular expression.

A window is specified by its caption, and one of five different search options can be selected using the Match parameter. If the function succeeds, it returns a unique window identifier.

Return Values

If the function finds the specified window, it returns a unique numeric identifier for the window. If it fails, it returns 0.

Parameterization

The argument Caption can be parameterized.

Example

In the following example, the ctrx_find_window_by_name function searches for a window with the caption "Microsoft Edge" using case-sensitive comparison. It returns the numeric identifier of the window. The lr_log_message function prints the identifier to the log.

Copy code
lr_log_message("window identifier: %d", ctrx_find_window_by_name("Microsoft Edge", MATCH_Exact));