Jump to content
  • Advertisement
Sign in to follow this  
GizmoC

Programatically pressing keys or moving the mouse?

This topic is 4415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I am not sure if this is the right forum for this question, apologies. Is there a way by which I can programmatically move the mouse? or press certain keys on the keyboard? Regards,

Share this post


Link to post
Share on other sites
Advertisement
Sorry, but you will need to give us much more information before somebody can give you a meaningful answer.


What are you trying to a achieve and where? Is this in windows, and you want to write a program to move the mouse pointer by pressing a key? Are you writing a game, and want to move you game's pointer when you press a key?

Share this post


Link to post
Share on other sites
To move the cursor, you can use SetCursorPos(). For keyboard, you can try using SetKeyboardState(). You can also do both with SendInput().

Share this post


Link to post
Share on other sites
Quote:
Original post by maxpenguin
Sorry, but you will need to give us much more information before somebody can give you a meaningful answer.


What are you trying to a achieve and where? Is this in windows, and you want to write a program to move the mouse pointer by pressing a key? Are you writing a game, and want to move you game's pointer when you press a key?


I am trying to create a program that makes a macro for an external DirectX game.

Heres how it works:
1) I start my program, I click "Record Input"
2) Now I do a sequence of keystrokes with my keyboard.. maybe even move the mouse around. the program records all these inputs.
(The above step seems straightforward, I think)
3) Click "Stop Recording".
4) I start a game.
5) I run my program's recorded macro... so now what happens is that all the keystrokes and mouse movements I recorded earlie, are replayed in game.

I dont know how to go about doing Step 5. I dont know how I can programmatically replay my recorded keystrokes.
I am guessing I'll have to invoke a Win32 method or event.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!