Could anyone post a full example code if Id like my program to move my mouse to the coords 100,100 and make it click there?
Thanks a lot.
Printable View
Could anyone post a full example code if Id like my program to move my mouse to the coords 100,100 and make it click there?
Thanks a lot.
Windows?
If this is a Windows program, post your question on the Windows forum. It's easy to do (assuming you already have the code to create the window), but I don't remember the functions off the top of my head... and I don't have my Petzold book with me. There's a Windows API function to move the cursor, and there's a function to send a mouse-click message to your program.
If you're looking for an easy way to automate an existing application (without using WinAPI, C, or C++) check out WinBatch. It took me about a day to learn WinBatch... I've been fooling around with the WinAPI off & on for years, and I'm still a beginner!
Well, yeah I posted wrong then.
Its a windows program.
Just post here instead of making 2 threads.
I know its SetCursorPos or something, but never really understood the "POINT" function.
Its like you have the x and the y variables in one.
Dont know how to do that.
And I dont know how to make it actually click.
What have you got so far?
A POINT is a structure of two integers, one for the x and one for the y coods. Remember that the coords can be relative to the top left corner of the screen or top left of the window capturing the mouse. ClentToScreen() or ScreenToClient() will convert.
POINT ptMouse;
ptMouse.x=100;
ptMouse.y=100;
//convert to or from client / screen coords
Send mouse msg WM_LBUTTONDOWN with SendMessage(). May find MAKELPARAM() macro useful (windows.h)
There has been code posted here, try a search.
Also see this mouse-related thread.