Getting “global” mouse position in Mac OS X

前端 未结 5 463
醉话见心
醉话见心 2020-12-24 02:41

How can I get in Mac OS X \"global\" mouse position - I mean how can I in cocoa/cf/whatever find out cursor position even if it\'s outside the window, and even if my window

5条回答
  •  忘掉有多难
    2020-12-24 03:31

    Matt is correct, but in order to continuously get the coordinates, I believe the other option is to use event monitor provided by NSEvent. Try addGlobalMonitorForEventsMatchingMask:handler: and addLocalMonitorForEventsMatchingMask:handler:. Check NSEvent Class Reference for more detail.

提交回复
热议问题