gpt4 book ai didi

macos - Mac App Store 中的应用程序能否获得辅助功能许可?

转载 作者:行者123 更新时间:2023-12-03 12:20:25 28 4
gpt4 key购买 nike

我有一个应用程序(使用 ElectronJS 制作)依赖于具有辅助功能权限来监听鼠标/键盘事件(通过 iohook 包)。我想把它放在 Mac App Store 上,但看起来:

  1. Mac App Store 需要沙盒和
  2. 沙盒不允许辅助功能权限。

因此 Mac App Store 中的应用程序无法获得辅助功能权限。这是正确的还是我遗漏了什么?

最佳答案

您需要使用 AXIsProcessTrustedWithOptions 来请求访问辅助功能权限。

这是 Apple 的完整文档:https://developer.apple.com/documentation/applicationservices/1459186-axisprocesstrustedwithoptions

例子:

let promptFlag = kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString
let myDict: CFDictionary = NSDictionary(dictionary: [promptFlag: true])
AXIsProcessTrustedWithOptions(myDict)

if (AXIsProcessTrustedWithOptions(myDict))
{
//we have permission granted here
}

关于macos - Mac App Store 中的应用程序能否获得辅助功能许可?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61847744/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com