Answer the question
In order to leave comments, you need to log in
How to hold down keys on the keyboard in C++?
How to create a keypress in C++? I do this code and it just presses and immediately releases the key:
#include <iostream>
#include <windows.h>
int main()
{
keybd_event(0x57, 0, 0, 0);
}
Answer the question
In order to leave comments, you need to log in
Here's how in Delphi
procedure SimulateKeyDown(Key: Byte);
begin
keybd_event(Key, 0, 0, 0);
end;
procedure SimulateKeyUp(Key: Byte);
begin
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
end;
procedure SimulateKeystroke(Key: Byte; Extra: DWORD);
begin
keybd_event(Key, extra, 0, 0);
keybd_event(Key, extra, KEYEVENTF_KEYUP, 0);
end;
KEYEVENTF_KEYUP (0x0002)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question