gpt4 book ai didi

applescript - 如何在 Applescript 中将 UI Elements Enabled 设置为 true?

转载 作者:行者123 更新时间:2023-12-04 03:15:01 24 4
gpt4 key购买 nike

tell application "System Events"
if UI elements enabled is true then
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.universalaccess"
display dialog "This script requires access for assistive evices be enabled." & return & return & "To continue, click the OK button and enter an administrative password in the forthcoming security dialog." with icon 1
end tell
set UI elements enabled to true

if UI elements enabled is false then return "user cancelled"
delay 1
end if
end tell

当我运行这个时,我收到一个错误。 “无法将应用程序启用的 UI 元素设置为 true”

任何想法为什么会发生这种情况?

额外信息:OS X Yosemite

最佳答案

自 OS X Mavericks 以来,启用的 UI 元素是只读属性。尝试这个:

tell application "System Events"
if not UI elements enabled then
display dialog "This script requires access for assistive devices be enabled." & return & return & "To continue, click the OK button and enter an administrative password in the forthcoming security dialog." with icon 2
if button returned of result is equal to "OK" then
do shell script "sudo sqlite3 'Library/Application Support/com.apple.TCC/TCC.db' 'insert or replace into access values (\"kTCCServiceAccessibility\",\"com.apple.ScriptEditor2\",0,1,0,null);'" with administrator privileges
end if
end if
end tell

关于applescript - 如何在 Applescript 中将 UI Elements Enabled 设置为 true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26767628/

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