0

I have tried everything I found in google but nothing works. I want to press A for 5 seconds, but everything presses it only once.It just releases it immediately. Pressing multiple times is not the answer because the key must be pressed for atleast 30ms.

const int KEYEVENT_KEYUP = 0x02;

keybd_event(0x41, 0, 0, 0);
Sleep(5000);
keybd_event(0x41, 0, KEYEVENT_KEYUP, 0);
Maineri
  • 53
  • 7
  • Loop like a madman on the keybd_event with a thread maybe ? – rak007 Sep 21 '17 at 13:09
  • @rak007 it can't be the best way to do it. – Maineri Sep 21 '17 at 13:12
  • Look like it is unfortunately with the win API : https://stackoverflow.com/questions/17982409/simulate-a-keypress-for-x-seconds – rak007 Sep 21 '17 at 13:13
  • Holding a key down is reinterpreted as repeated key presses *by the keyboard.* – Chris Sep 21 '17 at 13:43
  • How can I repeat it so fast. I tried while loop, but it was a lot slower than just pressing a key down. I am currently trying to make a new thread for it, but have no experience in c++ threads. – Maineri Sep 21 '17 at 13:52
  • @rak007 Looks like the software I am doing this doesn't accept too fast taps. It must be pressed for 30ms or something. I am completely stuck now. – Maineri Sep 21 '17 at 14:15
  • Still not solved – Maineri Sep 21 '17 at 22:18

0 Answers0