Use Cursor.Position to set the mouse cursor position. This is the easy
part
The advanced part is to simulate the mouse clicks. I assume you want to
send the mouse clicks to specified control on which you like to
position the mouse cursor, right? This requires use of the Win32 API.
You have to import the following functions from user32.dll:
SendMessage - definition -
http://msdn.microsoft.com/library/d...agesandmessagequeuesfunctions/sendmessage.asp
WindowFromPoint - the definition of this func -
http://msdn.microsoft.com/library/d...reference/windowfunctions/windowfrompoint.asp
Also define the following constants:
WM_LBUTTONDOWN = 513 //the Left Mouse Button when it is down
WM_LBUTTONUP = 514 //the left mouse button is up
WM_RBUTTONDOWN = 516 //the Right Mouse Button when it is down
WM_RBUTTONUP = 517 //the Right mouse button is up
The algorithm:
Change the position of the cursor with Cursor.Position, get the handle
of the control (actually it is the window, in windows everything is
window - even the buttons) with the help of WindowFromPoint (pass the
coordinates of the mouse as parameters to this func). After you get the
handle use SendMessage(MyHandle, WM_LBUTTONDOWN, 0, 0); This is not
enough tho, after that you need to call SendMessage(MyHandle,
WM_LBUTTONUP, 0, 0); to tell the control that the mouse button is
released and the control will do its duty as the user clicked the mouse
on it.
I know it will sound complicated especially if you are new to Windows
programming, but someone can help with the definition of these Win32
API funcs in C#. I do not code in C# so it for it will be difficult to
explain you how to do it. I just can give you the algorithm.
Philip