How can I set the mouse position?

前端 未结 5 1407
谎友^
谎友^ 2021-01-15 03:54

I need to set the position of the mouse on the screen. In some other similar question, it was suggested to use CGDisplayMoveCursorToPoint(CGDirectDisplayID display, CG

5条回答
  •  臣服心动
    2021-01-15 04:21

    Try CGWarpMouseCursorPosition(). It doesn't require a display ID.

    If you want a display ID, you can pick an element, using whatever criteria you like, from the array returned by [NSScreen screens]. Invoke -deviceDescription on that NSScreen object. From the dictionary that's returned, invoke -objectForKey: with the key @"NSScreenNumber".

提交回复
热议问题