0

I'm using SendInput() (using InteropServices, C#) with scancodes as argument. However, I don't manage to send combinations using R-ALT. I'm using Mac with Bootcamp and the R-ALT scancode is registered as 1x38 (R-ALT + L-Control) but I can't use 138 (1x38?) as a scancode argument (ushort/int).

Error message is just "The name x38 does not exist in the current context".

How do I properly use scancodes like 138 as argument in SendInput()?

agoSwitch
  • 21
  • 2
  • Right-Alt is an extended key, scan code 0xE0 0x38. So set wScan to 0x38 (not x38), dwFlags to KEYEVENTF_EXTENDEDKEY to tell it to expect the 0xE0 prefix. – Hans Passant Dec 06 '21 at 16:34
  • Thanks @HansPassant, it works to synthesize the extended key combination. My issue now is that I don't understand how to release the extended key properly. Earlier I sent 4 keys e.g shift keydown, 6 keydown, 6 keyup, shift keyup (simulation of "&") but when changing keydown to the extended key, the key is pressed until I reboot. Any idea? – agoSwitch Dec 14 '21 at 07:20
  • I'd guess you forgot to turn both flags on, set dwFlags to `KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP` – Hans Passant Dec 14 '21 at 08:51

0 Answers0