尝试在m中模拟python中的fn键

2024-04-28 19:49:59 发布

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

我试着在mac上模拟双fn键来开始听写,到目前为止,我已经阅读了所有的文档,并应用了一些解决方案,但都是徒劳的。 我试着从python代码中打开听写。从终端执行。到目前为止我已经试过了,但没有成功。你知道吗

from Quartz.CoreGraphics import CGEventCreateKeyboardEvent
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGHIDEventTap

evt = [CGEventCreateKeyboardEvent(None, 0x3f, True), 
        CGEventCreateKeyboardEvent(None, 0x3f, False), 
        CGEventCreateKeyboardEvent(None, 0x3f, True), 
        CGEventCreateKeyboardEvent(None, 0x3f, False)]
CGEventPost(kCGHIDEventTap, evt)

有人能告诉我哪里出了问题吗?你知道吗


Tags: from文档importnonefalsetruemac解决方案