I was wondering how can I simulate a key depression in C++. Such as having code that when I run the program it presses the letter "W" key. I don't want to be displaying it in a console window I just want it to display the "W" key every time I click on a text field. Thanks!
Note: I am not trying to make a spammer.
It looks like you want to use either SendInput()
or keybd_event()
(which is an older way of doing the same thing).
How can I fire a key press or mouse click event without touching any input device at system level?
Oh, by the way, you probably don't want to do this stuff; if you are simulating key-presses to make your application behave the way you want it to, then you might want to rethink how you are designing your application. In my experience sending key presses and intercepting them causes nothing but woes.