Limiting mouse to one display on Mac (Potentially using Cocoa)

后端 未结 1 1849
天涯浪人
天涯浪人 2021-01-03 02:43

I\'ve been feverishly searching for a method by which to limit the user\'s mouse to one display in a multi-display setup on a Mac.

I\'ve stumbled upon this question

相关标签:
1条回答
  • 2021-01-03 03:11

    Use a Quartz Event Tap to filter mouse moved and mouse dragged events. In the tap callback, use CGEventSetLocation to modify the location of mouse events that would otherwise move off the main screen.

    You may need to run the program as root, or have assistive device access enabled in System Preferences.

    Quartz Event Services Reference

    0 讨论(0)
提交回复
热议问题