2

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?

Alister
  • 6,527
  • 4
  • 46
  • 70

1 Answers1

2

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...

Alister
  • 6,527
  • 4
  • 46
  • 70
  • 1
    Don’t use `keybd_event()`, it is long deprecated. Use [`SendInput()`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput) instead. – Remy Lebeau Jan 19 '21 at 03:08