Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript display image

I have a weather map image online that I'd like to have an applescript pull up.



Basically I just want it to pull up in a dialog box maybe or something like that. Is that possible to do?

Mac OS X (10.7.1)

Posted on May 8, 2012 10:33 PM

Reply
19 replies

May 14, 2012 11:08 AM in response to derekshull

Ok, I think I've tracked down the issue with your script (Red Menace's last script handles things differently). in that 20 second repeat loop near the end of your script all events get passed back to the system, so trying to reopen the window during that period (which is an event) will always fail.


Red's last version fixes this by simply leaving the app and window open for 20 seconds. if that works, great; if not, it can be tweaked out more. let us know.

May 14, 2012 12:45 PM in response to twtwtw

There aren't any statements to reopen the window if it is closed - this was why the window wasn't set to release if closed, in case it might later need to be reshown (depending on if the application quits when the window is closed). Sending all events back to the system shouldn't affect the window display, since the system/application is what takes care of stuff like that, although there may still be a lag in getting the events to where they need to be - sleeping the application wasn't really the way to go, but using the delay command is worse, especially since its timing seems to be broken in ASOC.


The events will get backed up in the queue if the UI is blocked, which was the reason for breaking up the sleep time in the first revision. Getting a selector from a regular script was the missing piece, which I was looking at for another project - using a script object in the main.scpt solved that puzzle, so I was able to use the performSelector...afterDelay and get rid of that other stuff (it also made the application more responsive and quit correctly if the window was closed, if the delegate handler was added per the initial comments).


I'm still working out the nuances of the Cocoa-AppleScript applet, but both scripts seem to work OK on my machine, although the latest one uses a better method for the delay.

May 14, 2012 1:10 PM in response to red_menace

I'm just pointing out what I see on my machine. When I use derekshull's version (adding a 'log theEvent' command into the fetchEvents() handler, then so long as I see log entries in console the window can't be reopened. That just answers the question he had as to why the panel was behaving oddly: he was (I'm guessing) trying to reopen it too quickly. It doesn't apply to your last version, which seems to work fine, except that it only keeps the window open 20 seconds.


Incidentally, have you tried trapping the 'window closed' notification instead? That would allow you to avoid the script object and performSelector command.


One oddness. on my machine (10.7.4) I have to use (note the pipes):


current application's |NSURL|'s URLWithString_(imageURL)


otherwise NSURL is lowercased to nsurl and throws an error. That doesn't happen on your machine?

May 14, 2012 1:28 PM in response to twtwtw

The performSelector is just used to quit the application after a 20 second delay - using the delay or various sleep commands will block the UI unless other steps are taken.


You might have to close and reopen the Script Editor to keep it from remembering a previous capitalization. My first use of the NSURL term was all caps, so I don't need to use the pipes. I think the term was reserved in a previous version, so that also might have something to do with it.

Applescript display image

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.