简体   繁体   English

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

[英]Using Appkit and Python to hide mouse cursor on OSX

I'm trying to script hiding the mouse cursor on OSX 10.9. 我正在尝试将鼠标光标隐藏在OSX 10.9上。 I have Chrome starting and going full screen for a kiosk and I'd like to periodically run a script to hide the cursor. 我有Chrome启动和全屏显示自助服务终端,我想定期运行脚本来隐藏光标。

Applescript no longer directly supports "call method" to call the objective C method, so I thought the simplest method would be to use AppKit from the provided python. Applescript不再直接支持“调用方法”来调用目标C方法,所以我认为最简单的方法是使用提供的python中的AppKit。

It crashes: 它崩溃了:

$ 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 there is a pre-requisite call I need to make to initialize something , but I haven't found anything yet while digging through docs/google. 我怀疑在初始化某些内容时需要进行必要的调用,但是在挖掘docs / google时我还没有找到任何东西。

What am I missing? 我错过了什么?

I've had luck with the Quartz included with PyObjC : 我和PyObjC附带的Quartz一起运气好了:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM