How to emulate system-wide mouse click?

S

Sin Jeong-hun

The term 'system-wide' just means that click is dealt in whole-screen
wide level.
Just like the real mouse pointer.
What I'd like to do is to emulate mouse move and click.
For example, the command is something like
"Move the mouse to the 300,400 of the screen and click."
I know that I can send mouse clcik message to a specific window using
WinAPI. But can't I just emulate 300,400 click of the real screen?

I thought that I might need to deal with the mouse driver?

A workaround I came up with is to find the window at that screen
location using WindowFromPoint then translate the point to that
window's cordinate then send WM_MOUSEDOWN.
But is this the only way?

Please give me a hint. Thank you.
 
N

Nicholas Paldino [.NET/C# MVP]

Sin Jeong-hun,

In order to do this, you will want to call the SendInput API function
through the P/Invoke layer. It will allow you to emulate input into the
system (this is how drivers do it, I believe).

In the case of a mouse click, it would then trigger all of the actions
that would result from that input. You can synthesize keyboard input as
well, if you wish.
 
S

Sin Jeong-hun

Sin Jeong-hun,

In order to do this, you will want to call the SendInput API function
through the P/Invoke layer. It will allow you to emulate input into the
system (this is how drivers do it, I believe).

In the case of a mouse click, it would then trigger all of the actions
that would result from that input. You can synthesize keyboard input as
well, if you wish.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


The term 'system-wide' just means that click is dealt in whole-screen
wide level.
Just like the real mouse pointer.
What I'd like to do is to emulate mouse move and click.
For example, the command is something like
"Move the mouse to the 300,400 of the screen and click."
I know that I can send mouse clcik message to a specific window using
WinAPI. But can't I just emulate 300,400 click of the real screen?
I thought that I might need to deal with the mouse driver?
A workaround I came up with is to find the window at that screen
location using WindowFromPoint then translate the point to that
window's cordinate then send WM_MOUSEDOWN.
But is this the only way?
Please give me a hint. Thank you.
Thank you very much for the information.
I will try it.
Good bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top