S
S
Sincous2011-05-22 10:43:31
Delphi
Sincous, 2011-05-22 10:43:31

Delphi - software emulation of holding keyboard buttons

I'm trying to solve the problem - to emulate holding the keys q, w, e, r, t, y with a given time limit.
Similar to how we hold down the key for example in this text field

for 2 seconds : I tried to do it like this: But in this case, the number of characters will be different from if I held down the key myself (200 characters will be entered) + I think this approach is wrong. Tell me in which direction to dig in order to achieve a realistic input of a pressed key :)

C := ord('Q');
keybd_event(C,0,0,0);
sleep(2000);
keybd_event(C,0,KEYEVENTF_KEYUP,0);




C := ord('Q');
for i := 1 to 200 do begin
keybd_event(C,0,0,0);
sleep(10);
end;
keybd_event(C,0,KEYEVENTF_KEYUP,0);


Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mercury13, 2011-05-22
@Mercury13

Auto-repeat of buttons, unfortunately, will have to be implemented by yourself.

R
Riateche, 2011-05-22
@Riateche

Use the registry key KEY_CURRENT_USER\Control Panel\Keyboard\KeyboardSpeed.

G
gl00k, 2011-05-22
@gl00k

Moreover, you can run a separate thread that will repeat the keystroke with the necessary delay (as indicated by), and when to suspend.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question