shau-kote Posted April 1, 2016 Share Posted April 1, 2016 Hello. Today I've experimented with Safari's windows management through Alfred & AppleScript and encountered with greatly strange issue. As you probably know, every window object in AppleScript has standard properties which are described in Standard Suite: id, name, miniaturized and the like. In Script Editor I can obviously get any of these properties and I thought I can do the same in Script Filter too. However when I try to get miniaturizable and miniaturized properties in a Script Filter's script, the script fails with an error "Safari got an error: Can’t make |miniaturized| of item 1 of every window into type reference." under number -1700. I've created this simple example to illustrate the issue: repeat with safari_window in every window of application "Safari" try log (get miniaturized of safari_window) on error msg number -1700 log msg end try end repeat When I run it in Script Editor it executes as expected and logs true/false values, but when I call it from Script Filter it produces errors and logs error messages: [STDERR: alfred.workflow.input.scriptfilter] Safari got an error: Can’t make |miniaturized| of item 1 of every window into type reference. Safari got an error: Can’t make |miniaturized| of item 2 of every window into type reference. Safari got an error: Can’t make |miniaturized| of item 3 of every window into type reference. Safari got an error: Can’t make |miniaturized| of item 4 of every window into type reference. Safari got an error: Can’t make |miniaturized| of item 5 of every window into type reference. Safari got an error: Can’t make |miniaturized| of item 6 of every window into type reference. Safari got an error: Can’t make |miniaturized| of item 7 of every window into type reference. Also it isn't a Safari issue. Other applications behave the same way. Can someone explain me, why is it happening? Thank you. Link to comment
deanishe Posted April 1, 2016 Share Posted April 1, 2016 Can't say why it doesn't work beyond that AppleScript often behaves differently when called in different ways. In any case, this works just fine: tell application "Safari" repeat with safari_window in every window try log (get miniaturized of safari_window) on error msg number -1700 log msg end try end repeat end tell Link to comment
shau-kote Posted April 2, 2016 Author Share Posted April 2, 2016 Thank your so much again, deanishe. Your version works fine even in Script Filter. While in Script Editor both version works without producing errors. Indeed, AppleScript is inconsistent at times. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now