Solved

Mouse?

Posted on 1999-01-15
2
151 Views
Last Modified: 2013-11-20
I would like to be able to programmatically move the mouse on the screen.  I would like to have the mouse automatically wrap from one side of the screen to the other.  Some Mouse drivers provide this functionality, I just want to know if it is possible.  Is there some way I can change the coordinates the mouse is at?
0
Comment
Question by:cyberuser
2 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 300 total points
ID: 1327768
To set your mouse to a specific location, you want to use the SetCursorPos function.  You provide it an X and Y value, and it will set the cursor to that position.  Here is an excerpt from the online help:

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.

To integrate this with your program, you would probably want to set a timer, and then continually check to see if the cursor is on a certain side of the screen (which can be determined with GetCursorPos, I think, and a call to GetSystemMetrics (SM_CXSCREEN) and SM_CYSCREEN)

If you have additional questions, please feel free to ask.  Thanks!
0
 

Author Comment

by:cyberuser
ID: 1327769
Thank you.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 127
only14 challenge 19 64
changeXy challenge 13 58
Sed question 2 49
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now