2

My app will need to simulate a key being held down during some time. I don't know how many time. Can I use the sendinput API for this?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Aaron de Windt
  • 16,794
  • 13
  • 47
  • 62

1 Answers1

1

SendInput can trigger events with INPUT structures including KEYBDINPUT. A KEYBDINPUT can specify key up and key down events using virtual keys or scan codes. So you want to use SendInput twice: send a key down event at the beginning, and a key up event at the end.

easeout
  • 8,665
  • 5
  • 43
  • 51
  • You will only receive that key press once. For example: `x` rather than `xxxxxxxxxxxxxx`. – huang May 13 '23 at 23:02