Alister
Alister

Reputation: 6837

Bring up the emoji panel from Delphi code

I want to bring up the Windows 10 emoji panel for a TEdit/TMemo from a speed button click. Could be done by simulating the Win+. key combo, but I'm not sure how to simulate the windows key.

The Emoji panel is shown below.

Windows 10 Emoji Panel

Suggestions?

Upvotes: 2

Views: 554

Answers (1)

Alister
Alister

Reputation: 6837

This seems to work

  keybd_event(VK_LWIN, 0, 0, 0); // Left Win down
  keybd_event(190, 0, 0, 0); // "." down
  keybd_event(190, 0, KEYEVENTF_KEYUP, 0); // "." up
  keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0); // Left Win up

as does (based on Remy's suggestion)

procedure ShowEmoji;
var
  k: array [0..3] of TInput;
  I: Integer;
begin
  ZeroMemory(@k,sizeof(k));

  for I := low(k) to high(k) do
   k[i].Itype := INPUT_KEYBOARD;

  k[0].ki.wVk := VK_LWIN;
  k[1].ki.wVk := 190;
  k[2].ki.wVk := 190;
  k[2].ki.dwFlags := KEYEVENTF_KEYUP;
  k[3].ki.wVk := VK_LWIN;
  k[3].ki.dwFlags := KEYEVENTF_KEYUP;

  SendInput(Length(k), k[0], SizeOf(TInput));
end;

But if there is a better suggestion...

Upvotes: 2

Related Questions