Solved

Mouse?

Posted on 1999-01-15
2
156 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Include multiple hostnames in this command? 3 55
Perl Awk Need Help 3 129
List out all word 7 320
matchUp  challenge 6 70
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.

821 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