Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to control the mouse?

Status
Not open for further replies.

Sherak

Programmer
Sep 1, 2003
83
0
0
GB
I.e. Can I write a application that will take control of the mouse pointer, say move it to a point on the screen and left click?
 
Yes, but why would you want to?


James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
I have been messing around with a chess engine and would like to program it to play net chess, I have written the software that scans the board and calculates a move now I just need to be able to move the peice. i.e. move mouse to X,Y then LMB down, move to X.Y LMB up.
 
You will need to look at the SetCursorPos API.

The SetCursorPos function moves the cursor to the specified screen coordinates. If the new coordinates are not within the screen rectangle set by the most recent ClipCursor function, Windows automatically adjusts the coordinates so that the cursor stays within the rectangle.

BOOL SetCursorPos(

int X, // horizontal position
int Y // vertical position
);


Parameters

X -- Specifies the new x-coordinate, in screen coordinates, of the cursor.

Y -- Specifies the new y-coordinate, in screen coordinates, of the cursor.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The cursor is a shared resource. A window should move the cursor only when the cursor is in its client area.
The calling process must have WINSTA_WRITEATTRIBUTES access to the window station.

See Also

ClipCursor, GetCursorPos, SetCaretPos, SetCursor, ShowCursor



James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Hi James,

Thats great, extrmemly simple! Thanks a lot, there is somthing as simple to emulate the clicking of the left mouse button is there?

Thanks,

PJ
 
See if this thread helps: thread101-723261 .


James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top