ImageEn, unit iexOtherClasses

TIERFBClient.SendKeyEvent

TIERFBClient.SendKeyEvent


Declaration

procedure SendKeyEvent(xkey: dword; down: boolean);
procedure SendKeyEvent(VirtualKey: dword; KeyData: dword; down: boolean);


Description

Sends a Windows Virtual Key or a XWindow key to the server.
The first overload (XWindow) is fully supported (you can send any XWindow key).
The second overload (VirtualKey) doesn't support all key combinations (like CTRL-?, ALT-?, etc...), so applications should handle these combination manually.

May throw EIERFBError exception if a communication error occurs.

Parameter Description
xkey XWindow key code
down True when the key is down, False otherwise
VirtualKey Windows Virtual Key code
KeyData Windows Virtual Key data


Example

// send CTRL-ALT-DEL
procedure TForm1.Send_CTRL_ALT_DEL();
begin
  if RFB.Connected then
  begin
    RFB.SendKeyEvent(VK_CONTROL, 0, true);
    RFB.SendKeyEvent(VK_MENU, 0, true);
    RFB.SendKeyEvent(VK_DELETE, 0, true);
    RFB.SendKeyEvent(VK_DELETE, 0, false);
    RFB.SendKeyEvent(VK_MENU, 0, false);
    RFB.SendKeyEvent(VK_CONTROL, 0, false);
  end;
end;

// a very primitive and buggy keyboard sender. Some combinations could not work (ie CTRL-C, ALTR-?...)
procedure TForm1.ImageEnViewVirtualKey(Sender: TObject; VirtualKey, KeyData: Cardinal; KeyDown: Boolean);
begin
  if RFB.Connected then
    RFB.SendKeyEvent(Virtualkey, KeyData, KeyDown);
end;

// we need to handle TABS and ARROWS
procedure TForm1.ImageEnViewSpecialKey(Sender: TObject; CharCode: Word; Shift: TShiftState; var Handled: Boolean);
begin
  Handled := true;
end;