Getting the cursor position on Mac OS X

I want to get the cursor position. Is there a standard feature for this? I am trying to make my program in C ++. I would like to avoid Cocoa. Not that I had anything against it, but I would like to make my program cross-platform.

+4
source share
1 answer

You can use the following Core Graphics API, in CGEvent.h :

 CGEventRef event = CGEventCreate(NULL); CGPoint cursor = CGEventGetLocation(event); CFRelease(event); 

(Note that you can still use Cocoa in a cross-platform program, you just need to split the platform-specific code into different files instead of using #define s.)

+9
source

All Articles