0

I'm creating a CGEvent as such:

let event = CGEvent(source: nil, mouseType: .leftMouseDown, mouseCursorPosition: ..., mouseButton: .left)

Now mouseCursorPosition requires Global Coordinates: https://developer.apple.com/documentation/coregraphics/cgevent/1454356-init

Now I believe Global Coordinates is that the Top Left corner is at 0, 0

Problem:

I have an NSPoint, which is expressed in the current view's coordinates. I need to convert that NSPoint into the Global Coordinates.

I saw this near duplicate: Mac OS X: Convert between NSView coordinates and global screen coordinates

However, when i try that code, it seems to still be in Screen Coordinates, which means that the top left corner is:

0, ScreenHeight

That's not good, it's supposed to be in Global Coordinates.

0 Answers0