Presses (but does not release) a mouse button in the window.
window.PressMouse ([iButton, iXpos, iYpos, bRawEvent])
|iButton||Optional: The mouse button to press: Windows: 1 for left (default), 2 for right, and 3 for center. NUMBER.|
|iXpos||Optional: The horizontal coordinate (relative to the current window) at which to press the mouse. You must also specify iYpos if you specify iXpos. The default is 0. INTEGER.|
|iYpos||Optional: The vertical coordinate (relative to the current window) at which to press the mouse. The default is 0. 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.|
PressMouse is a low-level method that most scripts do not have to call. In general, when interacting with an application, you use the Click function to click the mouse, or a method designed to perform the action desired, such as Pick to pick a menu item.
PressMouse moves the mouse to the object and presses the specified mouse button (if it is not already pressed). The mouse is moved to the iXpos and iYpos coordinates before pressing. These coordinates are relative to the client area of the window (that is, the window’s internal area, excluding its caption, menu bar, and border). If you do not specify coordinates, the press occurs in the upper left corner (0, 0) of the client area of the window.
If the coordinates fall outside of the window, Silk Test Classic raises the exception E_COORD_OUTSIDE_WINDOW unless the OPT_VERIFY_COORD option is set to FALSE.
PressMouse does not actually generate mouse events when called. Instead, the events are queued until all keyboard and mouse events have been released. For example, the code shown below does not release events until the call to ReleaseMouse.
You can call the AgentClass method FlushEvents if you want to do anything between pressing and releasing the mouse. Explicitly flushing events with FlushEvents is necessary if you want the mouse presses to happen now.
MainWin.PressMouse (1, 100, 100) MainWin.MoveMouse (100, 101) MainWin.MoveMouse (100, 102) MainWin.ReleaseMouse (1, 100, 103)// events released