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 simplistic keyboard sender. Some combinations will 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;