I cannot get this to work correctly. This should press the left button for 1 second, then wait 10 seconds, then right 1 second, etc .:
keybd_event(0x25, 0xCB, 0, 0);
cout << "Ldown\n";
Sleep(1000);
keybd_event(0x25, 0xCB, KEYEVENTF_KEYUP, 0);
cout << "Lup\n";
Sleep(10000);
keybd_event(0x27, 0xCD, 0, 0);
cout << "Rdown\n";
Sleep(1000);
keybd_event(0x27, 0xCD, KEYEVENTF_KEYUP, 0);
cout << "Rdown\n";
This is in a loop, but it won’t do anything :( If I don’t close the program before the key is released, then it just holds the key until I press the key again.
I know that you can use only one key code if you want, but I need to use both.
So what am I missing?
source
share