SetFocus


 

SetFocus>window_title

 

Sets focus to the specified window.  The window_title may contain the * symbol at the end to indicate a substring match.

 

If the WIN_USEHANDLE variable is set to 1 window_title must be a window handle.

 

If the last character of the window title specified is an asterisk (*), Macro Scheduler will attempt to setfocus to the first window whose title matches the text entered exactly. If it cannot make an exact match it then looks at all windows and sets focus to the first one it finds whose title contains the entered text (using a case insensitive search). This solves the problem with applications such as Word or Netscape which change their titles depending on the document loaded. It is best to try to provide an exact (including case) window title to ensure the correct window is found, as many applications have multiple invisible windows with similar names.  Specifying text without a trailing asterisk will force Macro Scheduler to only look for an exact match.

 

To summarise:

 

SetFocus>window_title

Searches for a window title matching window_title fully and case-sensitively.

 

SetFocus>window_title*

First performs an exact case-sensitive match as above and if nothing found does a case-insensitive substring search where window_title can be anywhere within the matching window title.

 

For more control regular expressions can be used if WIN_REGEX is first set to 1.

 

To set focus to child windows, such as MDI children, first use SetFocus to focus the application, and then issue a second SetFocus for the child window.  In most cases it is necessary to add the * symbol for child windows.

 

It is possible to limit the type of windows this command affects using the WF_TYPE variable:

 Let>WF_TYPE=0 - No Child Windows

 Let>WF_TYPE=1 - ALL Windows (Default)

 Let>WF_TYPE=2 - Visible Windows Only

 Let>WF_TYPE=3 - Child Windows Only

 

Abbreviation : Set

 

Example

 

SetFocus>notepad*

 

Child Window Example:

 

SetFocus>Opera*

SetFocus>google*

 

RegEx Example:

 

//find first matching window that starts with 1 or more printable characters and ends with "Notepad" (e.g. Untitled - Notepad)

Let>WIN_REGEX=1

SetFocus>.+Notepad$