使用Appkit和Python在OSX上隐藏鼠标光标

2024-04-16 22:08:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在OSX10.9上编写隐藏鼠标光标的脚本。我有Chrome启动和全屏为一个kiosk,我想定期运行一个脚本来隐藏光标。在

Applescript不再直接支持“call method”来调用objective C方法,因此我认为最简单的方法是使用提供的python中的AppKit。在

它崩溃了:

$ 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

我怀疑我需要进行一个先决条件的调用来初始化某个,但我在搜索docs/google时还没有找到任何东西。在

我错过了什么?在


Tags: 方法脚本default鼠标chromecallmethodmar