Macro Scheduler 15

IfWindowOpen

IfWindowOpen>window_title[,label_name[,false_label_name]]

 statements  

[ [Else

 else statements]

Endif ]

 

Checks to see if the specified window is open.  If so the first statements are executed.  Otherwise the else statements are executed.  Optionally, instead of Else and Endif a label or subroutine name can be specified.

 

When label names are specified the command causes the script to continue from the specified label without running any other lines of code in between. If a second false label is specified, execution will jump to that label if the expression resolves false.  Subroutine names can also be specified.  When specifying a subroutine name execution will jump to that subroutine and return to the line after the If statement when the subroutine has completed.

 

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 first attempt to find the first window whose title matches the text entered exactly. If it cannot make an exact match it then looks at all windows and selects 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.

 

It is possible to limit the type of windows this command effects 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

 

A Regular Expression can be used in window_title if WIN_REGEX is set to 1.

 

Abbreviation : IfW

See also: Label, Goto, IfFileExists, IfFileChanged, If, Subroutines

 

Example

 

IfWindowOpen>Notepad - [Untitled]

  ...

Endif

 

or, with a wildcard :

 

IfWindowOpen>notepad*

  ...

Endif