CitrixMouseClick Function

Action

Moves the mouse to a specified position and presses a specified button. Optionally, the mouse can be specified to move while the button is pressed. Key modifiers (such as Ctrl and Alt) can be provided. Timing parameters (such as mouse speed and key-down time) can be specified in profile settings (Citrix / Simulation / Mouse) or by an appropriate call to the CitrixSetOption function. Coordinates can be specified absolutely or relatively to a window (by providing a window handle).

The top left corner (of the screen or window) has the coordinates 0 / 0.

Include file

CitrixAPI.bdh

Syntax

CitrixMouseClick( in nX        : number,
                  in nY        : number,
                  in nWindow   : number optional,
                  in nButton   : number optional,
                  in nModifier : number optional,
                  in nDX       : number optional,
                  in nDY       : number optional ) : boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
nX X coordinate of the click position.
nY Y coordinate of the click position.
nWindow Window handle returned by a call to CitrixWaitForWindowCreation (optional). When this parameter is omitted or DESKTOP is specified, the provided coordinates must be relative to the desktop. When a window handle is specified, the nX and nY parameters state a position relative to the top left corner of the window (wherever the window is on the desktop).
nButton

Specify one of the following values (optional):

  • MOUSE_ButtonLeft (default): Left mouse button

  • MOUSE_ButtonRight: Right mouse button

  • MOUSE_ButtonMiddle: Middle mouse button

nModifier

Specify one of the following values (optional):

  • MOD_None (default): No modifier

  • MOD_Shift: Shift key pressed in combination with the mouse button

  • MOD_Ctrl: Ctrl key pressed in combination with the mouse button

  • MOD_Alt: Alt key pressed in combination with the mouse button

nDX Specifies how far the mouse moves on the X axis when the button is pressed (drag operation) (optional). When this parameter is omitted the mouse does not move after the button is pressed.
nDY Specifies how far the mouse moves on the Y axis when the button is pressed (drag operation) (optional). When this parameter is omitted the mouse does not move after the button is pressed.

Example:

transaction TMain
  var
  begin
    CitrixInit(640, 480);
    CitrixConnect("myserver", "myusername", "mypass", "mydomain", COLOR_16bit);
    CitrixWaitForLogon();
    hWnd6 := CitrixWaitForWindowCreation("ICA Seamless Host Agent", MATCH_Exact, 0x94C800C4, 0, 0, 390, 223);
    CitrixWaitForWindow(hWnd6, EVENT_Activate);
    CitrixWaitForWindowCreation("Program Manager");
    CitrixMouseClick(211, 197, hWnd6, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd6, EVENT_Destroy);
    CitrixMouseDblClick(41, 23, DESKTOP, MOUSE_ButtonLeft);
    hWnd8 := CitrixWaitForWindowCreation("My Documents", MATCH_Exact, 0x16CF0000, 171, 98, 328, 235);
    CitrixWaitForWindow(hWnd8, EVENT_Activate);
    CitrixMouseButtonDown(82, 13, hWnd8, MOUSE_ButtonLeft);
    CitrixMouseButtonUp(367, 44, false, DESKTOP, MOUSE_ButtonLeft);
    CitrixWaitForWindowPos(hWnd8, 285, 31);
    ThinkTime(5.41);
    CitrixMouseClick(317, 13, hWnd8, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd8, EVENT_Destroy);
    CitrixDisconnect();
  end TMain;