1.11M Members

controlling mouse with keyboard in Windows

 
0
 

Hi,

I'm trying to write a program for Windows that will control the mouse with the keyboard, but I'm not sure I understand how Windows works.

My theory is that I will need to send mouse event messages for the mouse and hook the messages from the keys that are used to control the mouse. And I thought that I was going to need to send those messages to the in-focus window via a handle, but there isn't a handle parameter in the message sending function...

So, the question is, "Do I send the messages with no destination?" and "Does the OS grab messages and route them itself?"

Can anyone tell me how that works?

Thanks,
Shawn

 
0
 

If you want to move the mouse, for example using your arrow keys, you would set up event handling using your windows procedure fuction, and depending on what key is pressed(determined throuhg a switch statement of your lParam), you move the mouse. Im not sure if there is a windows function you can call to move the mouse, but if you do some research Im sure you could figure it out.

 
0
 

I appreciate the response, but it doesn't seem like you answered the question I asked.
My question was more like, how does Windows work?

The intent behind my program is to replace all the functionality of the mouse with key presses. It will not have a graphical component. It will be a keyboard mouse.

As far as I understand it, an application receives events from the OS and it receives them only when it is "in-focus". If that's correct (maybe it's not), then when another program is in-focus, the key-combo's will not work.

My understanding is that the Windows Proc function of my program will have to hook the appropriate messages from the keyboard and replace them with mouse event messages.

Do you know if this is this correct?

 
0
 

My question was more like, how does Windows work?

WTF?? This question is going to take a lot longer to answer than you think lol

The intent behind my program is to replace all the functionality of the mouse with key presses. It will not have a graphical component. It will be a keyboard mouse.

My understanding is that the Windows Proc function of my program will have to hook the appropriate messages from the keyboard and replace them with mouse event messages.

If your program isn't going to be graphical then why are you programming with the Win32 API?

 
0
 

re: WTF -- Well, do you know? Can you give me brief overview?

re: Why Windows -- because most people use Windows... *shrug* ...and because you/I have to in order to control the mouse pointer/buttons.

 
0
 

Because I hope to replace the mouse with a different device which will not be using Windows accessibility options (although I appreciate the link...I did not know about Windows accessibility option).

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: