views:

649

answers:

2

Im using:

keybd_event(0x41, 0, 0, 0);

0x41 is a 'a'. But that just prints one 'a' to the screen. I need it to hold down the key. And when i call

keybd_event(0x41, 0, KEYEVENTF_KEYUP, 0);

it must release the key.

Is that possible?

A: 

What are you trying to accomplish? The keys that are intended to remain pressed should already do so with your first line.

Here's the documentation for keybd_event(). Maybe it will help answer your question. (And maybe you needed the GetKeyboardState() method?)

If you're simply trying to repeatedly strike a key, it would be easier to loop around the first call than to try to get the system to auto-repeat. You can find the proper delay to use in the system information API functions.

John Fisher
Hm, ok. Well hoped i could do it would a loop/timer. But i guess that will do the trick.
Intosia
* thats without
Intosia
+1  A: 

You could replace the keybd_event call with SendInput. You can insert as many keystroke events as the event system will allow. The function returns the number of events successfully inserted.

Kristo