自动化程序中的AppleScript错误(“运行AppleScript”操作遇到错误)

9

我希望找到一种通过键盘快捷方式禁用/启用热角的方法。 我发现了这个苹果脚本

property theSavedValues : {"Mission Control", "Desktop", "Dashboard", "Launchpad"} -- for example

tell application "System Preferences"
    set current pane to pane id "com.apple.preference.expose"
    tell application "System Events"
        tell window "Mission Control" of process "System Preferences"
            click button "Hot Corners…"
            tell sheet 1
                tell group 1
                    set theCurrentValues to value of pop up buttons
                    if theCurrentValues is {"-", "-", "-", "-"} then
                        repeat with i from 1 to 4
                            set thisValue to item i of theSavedValues
                            tell pop up button i
                                click
                                click menu item thisValue of menu 1
                            end tell
                        end repeat
                    else
                        copy theCurrentValues to theSavedValues
                        repeat with i from 1 to 4
                            tell pop up button i
                                click
                                click last menu item of menu 1
                            end tell
                        end repeat
                    end if
                end tell
                click button "OK"
            end tell
        end tell
    end tell
    quit
end tell

我用这个Apple脚本在Automator中创建了一个服务,并将其附加到键盘快捷键上。每当我在Automator中运行此脚本时,它都可以正常工作,但是当我按下快捷键时,会出现“操作“运行AppleScript”遇到错误”的提示。

有什么办法可以解决这个问题吗?

谢谢。

1个回答

14

哦,我的天啊,我感觉自己太蠢了,唯一需要做的就是授予我使用此服务的应用程序的辅助功能权限:).

您可以通过前往(Mac OS)设置 -> 安全性与隐私 -> 辅助功能 -> 并找到您正在运行服务的应用程序来执行此操作。(在我的情况下,它是Finder。)


4
请前往(Mac OS)设置 -> 安全性与隐私 -> 辅助功能 -> 找到正在运行服务的应用程序,例如我的情况是Finder。 - beretis
2
尽管应用程序在“首选项>安全性与隐私>隐私”选项卡中已经有了复选标记,但这种情况仍然发生在我身上。将复选框切换关闭然后再次打开即可解决问题。 - clozach
1
感谢@beretis发布您的解决方案。我尝试了所有方法,但当我将Safari添加到辅助功能选项卡中时,它开始工作了... - AFK

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接