CloseWindow


 

CloseWindow>window_title

 

Attempts to close 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.

 

Please note: this command simply sends the internal Windows WM_CLOSE message to the target window.  This is the internal instruction to tell the window to close.  However, applications all interpret this instruction differently and there is no guarantee that it will cause the window to close.  If CloseWindow fails to close the window we recommend simulating user input to close it instead (e.g. by sending ALT-F4 or equivalent).

 

If the specified window is the main window of an application, then that application will begin to close down.  Any processing that the application does on exit will be carried out as usual.

 

If the last character of the window title specified is an asterisk (*), Macro Scheduler will attempt to close 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 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

 

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

 

Abbreviation : Clo

See also: GetWindowPos, GetActiveWindow

 

Example

 

CloseWindow>notepad*