Jump to content
phantasm

Applescripts no longer work ... Script Editor hangs / not responding on Sierra.

Recommended Posts

Hi guys, wondering if anyone has a clue about what changed with applescripts and accessibility in macOS Sierra. Since upgrading to Sierra, it seems all of my workflows that use applescript no longer work. This is not exclusive to Alfred; I have tried running multiple scripts in Script Editor, and Script Editor ends up hanging on run.

 

In Alfred 3, no information shows in debug. Calling a workflow will just cause Alfred to stop responding.

 

Console does not show any Event errors in Alfred or Script Editor.

 

I haven't been able to find similar issues with other people in google searches or in this forum.

 

I have received some OS messages that I think may be involved as I've tried to run applescripts in both Alfred 3 and Script Editor (shown below). They seem to come up sporadically, and after a delay of running a script. I know it has been necessary to add SystemUIServer.app to Accessibility in System Preferences > Security & Privacy in past versions of Alfred and OS X in order to run certain workflows with applescripts. Since upgrading to Sierra, I am seeing a similar requirement. Adding /System/Library/CoreServices/SystemUIServer.app to Accessibility and checking it does not fix the issue.

 

Any clues to what may be going on is much appreciated :).

 

EDIT: I think it has something to do with "System Events." It looks like applecripts work until they come to

 

     tell application "System Events"

 

I have tried adding /System/Library/CoreServices/System Events.app to Accessibility, a shot in the dark; that didn't help either.

 

 

Screen Shot 2017-05-08 at 12.36.10 PM.jpg

Edited by phantasm

Share this post


Link to post

Hi deanishe, thanks, and thank you for your work throughout the years. Definitely not a reboot issue. Problem I'm having is Script Editor is not giving me any event information, and Alfred isn't giving me any debug information. Same thing with Console, as far as I've investigated (see below). Here are some scripts that either hang Script Editor / Alfred, or simply won't continue:

 

**interesting note- when I try to open all of these scripts in Script Editor, Script Editor stalls for a few minutes, then I am able to open any script and it shows up in a window right away.

**another interesting note- this is one familiar to me, I came across it when Apple first introduced iCloud Drive. When Apple started directing saved files to iCloud, rather than a local directory, I had a similar issue opening Script Editor every time in Yosemite or El Capitan, can't remember. Script Editor would hang on every open, whether or not I opened it by a script or simply selecting the application. Once I chose by default to save files of Script Editor in iCloud Drive rather than a local directory, the hang went away; Script Editor opened instantly. That prompted me to do the same thing in this current OS, Sierra. Similarly, once I chose to save files to iCloud Drive, Script Editor no longer hung on opening by itself, but still hangs on opening when opening the script files below (as described in the note above)

 

**third note, I think this is getting to the root of the issue:

I've noticed when I originally try to open Script Editor with one of these scripts, Console shows this error under Process > Finder:

 

   /System/Library/CoreServices/Finder.app/Content/MacOS/Finder    (/System/Library/Frameworks/Appkit.framework/Versions/AppKit/)

     Subsystem: com.apple.AppKit      Category: General    

     Activity ID: 0 Thread ID: 0xdbb    PID: 312

     < private >

 

and this under Process > Script Editor:

Detected missing constraints for <private>.  It cannot be placed because there are not enough constraints to fully define the size and origin. Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once.

 

and this under Process > Script Editor:

ERROR: Setting <private> as the first responder for window <private>, but it is in a different window (<private>)! This would eventually crash when the view is freed. The first responder will be set to nil.
<private>

 

 

Here's one that used to work that involves keystrokes:

 

set newIcon to (POSIX file "/Volumes/HDD/Sync/ICONS/ICONS/Chrome.icns") as alias
set theItem to (POSIX file "/Applications/Google Chrome.app") as alias

tell application "Finder"
    activate
    set infoWindow to open information window of newIcon
    set infoWindowName to name of infoWindow
end tell

tell application "System Events"
    tell «class pcap» "Finder"
        tell window infoWindowName
            delay 0.3
            «event prcskprs» tab
            delay 0.3
            «event prcskprs» "c" given «class faal»:command down
        end tell
    end tell
end tell

tell application "Finder"
    delay 0.5
    close infoWindow
    set infoWindow to open information window of theItem
    set infoWindowName to name of infoWindow
end tell

tell application "System Events"
    tell «class pcap» "Finder"
        tell window infoWindowName
            delay 0.3
            «event prcskprs» tab
            delay 0.3
            «event prcskprs» "v" given «class faal»:command down
        end tell
    end tell
end tell

tell application "Finder"
    delay 0.5
    close infoWindow
end tell

 

__________

 

Here's one with menu selections. It opens Notification Center in Notifications view:

 

tell application "System Events"
    tell «class prcs» "Notification Center"
        «event prcsclic» «class radB» "Notifications" of «class rgrp» 1 of window "NotificationTableWindow"
    end tell
end tell

 

 

__________

 

and here's a simple one, also using some keystrokes. It selects the icon in 'Get Info' and copies it's image content:

 

tell application "Finder"
    delay 0.1
    open selection using (path to application "Preview") -- open with Preview
end tell
delay 0.2
tell application "Preview"
    tell application "System Events"
        «event prcskprs» "a" given «class faal»:command down -- select all
        «event prcskprs» "c" given «class faal»:command down -- copy
        «event prcskprs» "w" given «class faal»:command down -- close window
    end tell
end tell

 

 

 

All of these used to work before Sierra.

 

I know this is a lot, thank you. But I think there is a simple solution..

 

Edited by phantasm

Share this post


Link to post

After you tried turning if off and on again, did you make sure it’s plugged in?


All joking aside, this clearly isn’t an Alfred bug, so you shouldn’t be asking here. Not because we wouldn’t help if we could — we definitely would — but because there are too few specialised eyeballs. Try Ask Different; that’ll likely your best bet.

Edited by vitor
Fixed typo

Share this post


Link to post

Thanks, I will. I didn't mean to waste anyone's time. Just thought I'd ask here considering the regular use of applescripts involved in workflows, and because Alfred has such a strong community here :).

Share this post


Link to post
9 minutes ago, phantasm said:

I didn't mean to waste anyone's time.

 

Not at all. It’s just that we’re not actually that many — just a handful of regulars. If your problem is Alfred-related, it’s likely we’ll be able to help you. But this is a macOS bug I’ve never heard of, so it’s likely few people have experience it, meaning you should get it in front of as many eyes as possible.

Share this post


Link to post

I hear ya. And thank you for your good work vitor. I've used your workflows throughout the years, actually some that don't work either right now because they have osascript. I'll figure it out!

Share this post


Link to post

I haven't had these errors in sierra either, but when I've seen <<class pcap>> and that sort of thing, it's because an app has been deleted.... Did you have scripting additions previously and maybe not reinstall them with sierra? (or something else installed in a location that might have been overwritten during the install?).

Edited by dfay

Share this post


Link to post

I think you're onto something. This is how the first script looks in another location I have it saved:

 

The keystroke lines seem to be having a problem...and they're controlled by System Events. As far as I know, I didn't install any scripting additions on previous OS's. Maybe they were installed by another package? Are there some very common ones?

 

 

 

set newIcon to (POSIX file "/Volumes/HDD/Sync/ICONS/ICONS/soundcloud.icns") as alias
set theItem to (POSIX file "/Applications/Soundcloud.app") as alias

tell application "Finder"
    activate
    set infoWindow to open information window of newIcon
    set infoWindowName to name of infoWindow
end tell

tell application "System Events"
    tell application process "Finder"
        tell window infoWindowName
            delay 0.3
            keystroke tab
            delay 0.3
            keystroke "c" using command down
        end tell
    end tell
end tell

tell application "Finder"
    delay 0.5
    close infoWindow
    set infoWindow to open information window of theItem
    set infoWindowName to name of infoWindow
end tell

tell application "System Events"
    tell application process "Finder"
        tell window infoWindowName
            delay 0.3
            keystroke tab
            delay 0.3
            keystroke "v" using command down
        end tell
    end tell
end tell

tell application "Finder"
    delay 0.5
    close infoWindow
end tell

 

 

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...