juancn
juancn

Reputation: 2613

"some script" is not allowed assistive access error on Mavericks

I have a script I use for laying out windows on a multi-monitor setup. After upgrading to Mavericks, I'm getting an error:

Organize Windows is not allowed assistive access.

After checking Apple support, I found this: http://support.apple.com/kb/HT5914 I followed the steps described there, I signed the applet, without much success. The error still happens.

First of all, the second prompt only happens if the script was exported as an application and placed in /Applications, if I place it in Documents (also bundled like an app) for example it does not pop-up.

All applets appear as "applet" in System Preferences when they do show up (which is odd since they have an identifier).

Has anyone had any success running this kind of script? Is there a way to disable the security check globally? (I presume not, but it's worth to ask)

What follows is the script, it just launches a couple of apps and places them on the screen:

#Query desktop area
tell application "Finder"
    set displayAreaDimensions to bounds of window of desktop
    set widthOfDisplayArea to item 3 of displayAreaDimensions
    set heightOfDisplayArea to item 4 of displayAreaDimensions
end tell

tell application "System Events" to tell process "Dock"
    set dockPosition to position in list 1
    set dockDimensions to size in list 1
    set heightOfDock to item 2 of dockDimensions
    set positionOfDock to item 2 of dockPosition
end tell

# Space between windows
set padding to 7

# This assumes that the Apple Cinema Display 27" is to the right
# of the Macbook Pro
set idea_w to 1600
set idea_h to 1440
set idea_base_x to 1680

set iterm_w to 2560 - idea_w - padding
set iterm_h to 1000
set iterm_base_x to idea_base_x + idea_w + padding

#If we're in a single monitor configuration
if widthOfDisplayArea is 1680 and heightOfDisplayArea is 1050 then
    # Override sizes
    set idea_base_x to 0
    set iterm_base_x to 0
    set idea_w to widthOfDisplayArea
    set idea_h to (heightOfDisplayArea - heightOfDock)
    set iterm_w to 1024
    set iterm_h to (heightOfDisplayArea - heightOfDock)
end if

checkRunning("IntelliJ IDEA 11", 10)
checkRunning("iTerm", 0)

placeWindow("IntelliJ IDEA", idea_base_x, 0, idea_w, idea_h)
placeWindow("iTerm", iterm_base_x, 0, iterm_w, iterm_h)

#Helper to launch as necessary
on checkRunning(theName, theDelay)
    if application theName is not running then
        tell application theName to activate
        delay theDelay
    end if
end checkRunning

on placeWindow(theProcess, x, y, w, h)
    tell application "System Events" to tell process theProcess
        set allWindows to (every window)
        repeat with aWindow in allWindows
            set position of aWindow to {x, y}
            set size of aWindow to {w, h}
        end repeat
    end tell
end placeWindow

Upvotes: 4

Views: 4680

Answers (2)

hepcat72
hepcat72

Reputation: 1124

Red Five's answer is great, but there are a couple more things to note.

Any time you edit the script to edit the use of assistive access features, signing & re-allowing assistive access only works for the pre-existing uses of assistive access features in the script. The new use of assistive access features will yield the "XYZ is not allowed assistive access." error. At that point, copying the script contents to a new script with a different name seems to be the only way to give the entire script the ability to use assistive access features. Other edits not involving assistive access features will require re-allowing assistive access and you do not need to copy the script. This makes debugging assistive access features rather cumbersome.

It is also noteworthy that if you have your code wrapped in a try block, you will not see the "XYZ is not allowed assistive access." error, so in order to debug, you should comment out your try/end-try lines.

There may be a way to circumvent the need for this, such as removing & re-apply the signing of the code, but I have not bothered to figure that out.

Upvotes: 2

Red Five
Red Five

Reputation: 86

I was having exactly the same problem with a script app I wrote to deal with a minor audio glitch. I set it to start at startup, allowed it in Assistive Access, and signed it as you found on Apple Support, and it still gave me that error on every startup.

What finally fixed it for me was to copy and paste the script code into a new script file, saved it again as an application but with a different name, and signed it, all before I ever ran it. When I finally ran it, it asked me if I wanted to allow it in Assistive Access, which I did, then I set it to start at boot like before. I just got through a reboot and it ran without any problems.

Upvotes: 7

Related Questions