Click here to Skip to main content
15,887,262 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day one and all,

I have written a small application that allows me to specify an application, and send it keystrokes or directed mouse-clicks.

I'm using keybd_event and mouse_event in the user32.dll. Now I've been successful in getting it working, however I understand that there are many uncertainties and pitfalls when doing this sort of thing and trying to achieve consistency.

Are there any measures I should or can take to ensure the success of the sent messages? I mean one key stroke not registering could make a big difference to the whole output of the app.

Any tips or ideas are welcome.

Thanks,

Jib.
Posted
Updated 21-Dec-10 23:20pm
v2

1 solution

All you can really do is check to make sure the target app is a) still running, and b) is still "responding". The way Task Manager checks to see if an app is running is that it uses SendMessageTimeout to send a WM_GETICON message to the app window and waits for a return value. If it doesn't get one within 5 seconds, it assumes the app is "Not Responding".

 
Share this answer
 
Comments
Jibrohni 22-Dec-10 6:46am    
Ok, I'll look into that. Thanks John.

I also read that keybd_event has been deprecated by SendInput. Would you recommend switching over to this method instead?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900