Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Mouse?

Posted on 1999-01-15
2
Medium Priority
?
165 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 1200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

971 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