Close Method (MoveableWin)

Class

MoveableWin.

Action

Closes the window.

Syntax

window.Close ([bConfirm, bSetActive])
Variable Description
bConfirm Optional: TRUE to close confirmation dialogs that may pop up when closing the window; FALSE (default) to raise an exception if a confirmation dialog pops up. BOOLEAN.
bSetActive Optional: TRUE to issue window.SetActive before attempting to close window. FALSE (default) to close without attempting to set window active. BOOLEAN.

Notes

The Close method attempts to close the window by trying the following events, in this sequence, stopping when the window closes:

  1. If a Close method is defined for the window, call it. Even if this method does not close the window, none of the following steps are executed.
  2. Call window.SysMenu.Close.Pick( ) (on platforms and windows that have system menus).
  3. If the window is a dialog box, type the keys specified in OPT_CLOSE_DIALOG_KEYS and wait one second for the dialog box to close.
  4. If there is a single button in the window, click that button.
  5. Click the list of buttons specified with OPT_CLOSE_WINDOW_BUTTONS.
  6. Select the menus specified with OPT_CLOSE_WINDOW_MENUS.
  7. Close() will use Alt+F4 if there is no File menu.

Close may fail. For example, if closing a window causes the application to display a message box and bCloseConfirm is set to FALSE, or if the buttons used to close the message box are not covered under the OPT_CLOSE_CONFIRM_BUTTONS option, the call will fail and raise the exception E_CANT_CLOSE_WINDOW.

This method supports several specifications you can make to help Silk Test Classic close a window:

To specify Set this option Or set this variable
Non-standard buttons to use to close confirmation dialog boxes OPT_CLOSE_CONFIRM_BUTTONS lsCloseConfirmButtons
Non-standard buttons to use to close the window OPT_CLOSE_WINDOW_BUTTONS lsCloseWindowButtons
Non-standard menu items to use to close the window OPT_CLOSE_WINDOW_MENUS lsCloseWindowMenus
Non-standard keys to type to close the window, if it is a dialog box OPT_CLOSE_DIALOG_KEYS lsCloseDialogKeys

You can make these specification, either by using the SetOption method, by defining the specified variable, or using the settings in the Close tab of the Agent Options dialog box.

Example

// Set the line number in GotoLine dialog to a string
GotoLine.LineNumber.SetText ("A")
GotoLine.Accept ()
// TextEditor displays a message box
MessageBox.Message.Verify ("Must enter a number.")
// close the message box
MessageBox.Close ()