Automatically Type Keys

How could you write a program that would automatically type what you tell it to? Like what kind of code would you use etc. ?

P.S: Sorry I only learned all the basics to C++ and some win32 basics too (like how to create a message box and window)
How could you write a program that would automatically type what you tell it to?


I'm not sure I understand this. Do you mean like you talk through a microphone and have it type that?
Oh sorry for not being too specific. I meant you type what you want in a textbox or something. Again sorry for the misunderstanding!
Thanks, but I am a bit rusty in c++ could you explain to me how to use this in a program? Or tell me the general idea? Thanks.
Do You want the program to type in text automatically?... Or do You want the User to enter text into a text-box?...
Well for now I am just trying to get it to actually type anything like 'a'. But yea I am hoping to work my way up to that!
I'm no Windows programmer, however...

This function simulates a keypress. It doesn't detect keypresses. For detecting keypresses, you may want: http://msdn.microsoft.com/en-us/library/ms646299(VS.85).aspx
You'll need a bool array[256] to store the data returned from this function.
This is just for when you work your way up to that level.

The function that simulates a keypress takes the key "name", a hardware scan code for the key that you will need to look into, any information needed about the keypress, such as if the key has a prefix byte that has the value of 224 (experiment to see if you need this) and if the key is being released, and something that for you should be zero.

You will need something to detect the keypresses, though.

-Albatross
try autohotkey it's open source.
Thanks, but I am a bit rusty in c++ could you explain to me how to use this in a program? Or tell me the general idea? Thanks.
Theres an example code at the bottom of the page
How could I change the example to type in a key like 'a'?
1
2
	keybd_event(VkKeyScan('a'), 0, 0, 0);
	keybd_event(VkKeyScan('a'), 0, KEYEVENTF_KEYUP, 0);
Last edited on
Where do I put that?


Topic archived. No new replies allowed.