CitrixKeyDown Function

Action

Presses a specified key. To release the key, call the CitrixKeyUp function. The window that has keyboard focus receives the key event.

Include file

CitrixAPI.bdh

Syntax

CitrixKeyDown( in nKey : number ) : boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
nKey

The key to type. Use a key number (ASCII code) or one of these predefined values:

  • KEY_Backspace

  • KEY_Tab

  • KEY_Enter

  • KEY_Shift

  • KEY_Ctrl

  • KEY_Alt

  • KEY_PageUp

  • KEY_PageDown

  • KEY_End

  • KEY_Home

  • KEY_LeftArrow

  • KEY_UpArrow

  • KEY_RightArrow

  • KEY_DownArrow

  • KEY_Insert

  • KEY_Delete

  • KEY_NumLock

See the CitrixApi.bdh for additional predefined values.

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");
    ThinkTime(8.25);
    CitrixMouseClick(219, 195, hWnd6, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd6, EVENT_Destroy);
    CitrixMouseDblClick(113, 20, DESKTOP, MOUSE_ButtonLeft);
    hWnd10 := CitrixWaitForWindowCreation("Microsoft Excel", MATCH_Exact, 0x15CF0000, -4, -4, 648, 460);
    CitrixWaitForWindow(hWnd10, EVENT_Activate);
    CitrixKeyDown(KEY_Enter);
    CitrixMouseClick(208, 268, hWnd10, MOUSE_ButtonLeft);
    CitrixKeyUp(KEY_Enter);
    CitrixMouseClick(630, 13, hWnd10, MOUSE_ButtonLeft);
    hWnd11 := CitrixWaitForWindowCreation("Microsoft Excel", MATCH_Exact, 0x94C801C5, 149, 206, 350, 108);
    CitrixWaitForWindow(hWnd11, EVENT_Activate);
    CitrixMouseClick(186, 85, hWnd11, MOUSE_ButtonLeft);
    CitrixWaitForWindow(hWnd11, EVENT_Destroy);
    CitrixWaitForWindow(hWnd10, EVENT_Destroy);
    CitrixDisconnect();
  end TMain;