AppleScript in automator error ("The action "Run AppleScript" encountered an error ")
Asked Answered
T

1

9

I wanted to find a way how to disable/enable hot corners via keyboard shortcut. I found this apple script

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

So I created an service in Automator with this apple script, attached it to keyboard shortcut, whenever I run this script in automator, it works but when i hit the shortcut, im getting "The action "Run AppleScript" encountered an error ". Any ideas what can be done to fix this? Thank you

Trousers answered 17/7, 2016 at 10:52 Comment(0)
T
14

Oh my god I feel so dumb, the only thing needed was to grant accessibility permission to app from which I'm using this service :).

You can do this by going to (Mac OS)Settings -> Security&Privacy -> Accessibility -> and finding the app from which you are running the service. (In my case it's Finder.)

Trousers answered 17/7, 2016 at 11:1 Comment(3)
Go to (Mac OS)Settings -> Security&Privacy -> Accessibility -> and find the app from which u are running the service, in my case its FinderTrousers
Happened to me even though the app already had a checkmark in the "Preferences > Security & Privacy > Privacy" tab. Toggling the checkbox off and then on again solved it.Duty
Thanks @Trousers for posting your solution. I tried everything, but when I added Safari to the Accessibility tab, it started working...Acetylate

© 2022 - 2024 — McMap. All rights reserved.