Using Appkit and Python to hide the mouse cursor on OSX

I am trying a script to hide the mouse cursor on OSX 10.9. I have a Chrome launch and a full screen for a kiosk, and I would like to run a script periodically to hide the cursor.

Applescript no longer supports the β€œcall method” for invoking the C object method, so I thought the easiest method would be to use AppKit from the provided python.

Failure:

$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import AppKit
>>> AppKit.NSCursor.hide()
Assertion failed: (CGAtomicGet(&is_initialized)), function CGSConnectionByID, file Services/Connection/CGSConnection.c, line 123.
Abort trap: 6

I suspect a preliminary call is required, which I need to make to initialize something, but I have not found anything yet, digging through docs / google.

What am I missing?

+4
source share
1 answer

, PyObjC:

import Quartz
Quartz.CGDisplayHideCursor(Quartz.CGMainDisplayID())
0

All Articles