1

Is there any way to get the coordinates of the mouse in Mac OS X? And further could you somehow manipulate the current mouse location using that method to retrieve the coordinates? Or would you have to use something else to move the cursor?

  • Writing a prank? Also, partial dup: http://stackoverflow.com/questions/1117065/cocoa-getting-the-current-mouse-position-on-the-screen and possible duplicate of http://stackoverflow.com/questions/2126622/how-to-store-and-use-the-current-mouse-position. See also http://stackoverflow.com/questions/2369806/simulating-mouse-clicks-on-mac-os-x-does-not-work-for-some-applications. – outis May 04 '10 at 01:38
  • @outis: No I'm not trying to pull... Also, those don't tell how to move the cursor do they? They just say how to get the coordinates unless I am mistaken. –  May 04 '10 at 01:50
  • http://stackoverflow.com/questions/2126622/how-to-store-and-use-the-current-mouse-position mentions setting the mouse cursor position. – outis May 04 '10 at 02:00
  • @outis: True, but I don't understand how CGEventMouseMoved would help move the coordinates of the mouse... –  May 04 '10 at 02:05
  • 1
    You can both read and write events to the stream with event taps. See the docs for more info (http://developer.apple.com/mac/library/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html). – Nicholas Riley May 04 '10 at 03:20
  • @Nicholas Riley: Ok, thanks. I'll check it out. –  May 04 '10 at 03:28
  • Why do you want to change the current mouse location? In general, the mouse is something that the user expects to be under his/her control. You won't be thanked for messing about with it. – JeremyP May 04 '10 at 08:11

1 Answers1

1

Not that you should generally do this, but there is a function to set the mouse location.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370