I\'m trying to move the location of a Mac cursor using Objective-C along a path outside of any UI element (not just on some window, but around the entire screen irrelevant o
The problem is that AppKit (which provides the NSEvent class) and Quartz Display Services (which provides CGWarpMouseCursorPosition) use different coordinate systems for the screen.
In Quartz, the origin of the screen coordinate system is at the top-left corner of the “main” screen, which is the screen that contains the menu bar, and Y coordinates increase as you move down the screen.
In AppKit, the origin of the screen coordinate system is at the bottom-left corner of the main screen, and Y coordinates increase as you move up the screen.
So if you ask AppKit for the mouse location (in screen coordinates), you need to convert the Y coordinate to the Quartz coordinate system before passing it to a Quartz function.
To transform the Y coordinate, you simply subtract it from the height of the main screen:
NSPoint point = [NSEvent mouseLocation];
point.y = [NSScreen mainScreen].frame.size.height - point.y;
CGWarpMouseCursorPosition(point);