Click Method (AnyWin PushButton)

Class

AnyWin and PushButton.

Action

Clicks either a window or a pushbutton.

Syntax

anyWin.Click ([iButton, iXpos, iYpos, bRawEvent])
Variable Description
iButton

Optional: The mouse button to press. On a Windows operating system, use 1 for left, 2 for right, and 3 for center. INTEGER.

You can also use the following mouse button identifiers:
  • MB_LEFT
  • MB_RIGHT
  • MB_MIDDLE
iXpos Optional: The horizontal coordinate (relative to the window) at which to click. If you specify iXpos, you must also specify iYpos. When you are working with the Classic Agent, the default coordinate is 0 for a window and the button center for a pushbutton. When you are working with the Open Agent, the default coordinate is the center of the window or the pushbutton. INTEGER.
iYpos Optional: The vertical coordinate (relative to the window) at which to click. When you are working with the Classic Agent, the default coordinate is 0 for a window, or the button center for a pushbutton. When you are working with the Open Agent, the default coordinate is the center of the window or the pushbutton. INTEGER.
bRawEvent 32-bit Windows only. Optional: Used to specify playback method. The Open Agent ignores this value regardless of what is specified in the script. BOOLEAN.

Notes

Click moves the mouse to the window or pushbutton and clicks the specified mouse button. The mouse is moved to the coordinates specified by iXpos and iYpos before performing the click. These coordinates are relative to the client area of the window or pushbutton (that is, the window’s internal area, excluding any caption, menubar, or border).

When you are working with the Classic Agent, and you do not specify coordinates, the click occurs in the upper-left corner (0, 0) of the client area of the window or in the center of the pushbutton.

When you are working with the Open Agent, and you do not specify coordinates, the click occurs in the center of the client area of the window or in the center of the pushbutton.

By default, Silk Test Classic verifies that the coordinates fall within the current window and generates the exception E_COORD_OUTSIDE_WINDOW if they do not. You can override this default by setting the OPT_VERIFY_COORD option to FALSE with the SetOption method.

Click cannot be used with a Menu or MenuItem.

Setting Focus on a Text Field in a Table

When using the Click method on a text field in a table you must use the coordinates 1,1—that is, specify Click(MB_LEFT,1,1)—in order to properly click within the text field and give it focus. As an alternative, you can use the SetFocus method on the text field to give it the input focus.

Example

// Restore Program Manager
ProgramManager.Restore ()
// Click on icon in top-left corner of Main group
ProgramManager.Main.Click (MB_LEFT, 35, 20)