Links for October 7, 2005

More on the System Events AppleScript bugginess

After a ton of testing and waves of frustration, I think this is finally ready to test again.

UIcheck() System Events Test Script 2 (, 10k)

Again, please run this and let me know what your results are, including OS version and a vague hardware description.

A few observations:

The script is much larger, but the re-useable parts are fairly self-contained. Most of the size comes from error logging and timing functions. Please feel free to pilfer whatever you want from this example.

One of the biggest problems noted by the previous test script was -609 “Connection is invalid” errors. Thanks to a great post and followup by Bill Cheeseman on the CocoaBuilder site, I figured out why those were happening.

Essentially, AppleScript was sending commands to an application which wasn’t ready yet or that was shutting down. For whatever reason, AppleScript doesn’t necessarily clear the reference to an application that’s been sent a quit command. It’s possible, and quite likely that sending a command to an application immediately following a quit command won’t restart the application, it will cause a -619 connection error since AppleScript will try to send the command to the vanishing application.

Additional testing proved that hypothesis. Several other applications all threw -619 errors when cycled too quickly. So these errors weren’t the issue. There were still occasional “-50 Parameter error” errors, which seem to occur randomly whenever sending a command to System Events. These appear to be the most traceable problem I’ve found.

That noted, System Events seems incredibly slow to quit. On 10.3.9 it requies two tries almost every time. After testing some delay statements to pause the script, I ended up looping around a try statement which quits and re-launches the application. If the application responds correctly, the try doesn’t fail and the repeat is exited.

Hopefully this will continue to work. In testing I found the scripts seems sensative to humidity, mean looks, cute girls and smelly lunches. They’d work one day and fail inexplicably the next. This iteration however, seems to be working.

The next step is to build in an error-catching loop into the iPhoto date setting routines to make sure the script doesn’t fail and skip over any photos.

Previous posting on this topic is here: AppleScript System Events Bug

Update Thanks to everyone who helped test this, I’ve rolled these functions into my iPhoto AppleScripts which should be more robust now.

Links for October 3, 2005

Becoming The Advocate

If one always argues as the Devil’s Advocate does one eventually come around to the Devil’s side?

It’s interesting to hold an opposite position from nearly everyone you know. Especially about something politically divisive. Everyone assumes you think like they do, lots of offensive stuff gets emailed and linked, people nudge you about things and expect something other than a blank stare. I’m good at the blank stare now. I’m also good at keeping my mouth shut and swallowing anger. People, even good smart people, just aren’t as accepting of differences as they think they are, and it’s just not worth the risk of finding out who can deal with it and who can’t. Yes, this is can be depressing at times.

Sort of related side note:

Last week a friend of a friend (of a friend…) was emailing around this short New Yorker column:

Day No. 1
And the Lord God said, “Let there be light,” and lo, there was light. But then the Lord God said, “Wait, what if I make it a sort of rosy, sunset-at-the-beach, filtered half-light, so that everything else I design will look younger?”
“Im loving that,” said Buddha. “It’s new.”
“You should design a restaurant,” added Allah.

What’s wrong with this picture? The Lord God and Allah are the same entity. How could the New Yorker let that slip? Are they honestly that ill-informed? Or was it perhaps a last minute “diversity-correction”, grepped in to appease the new gods of political correctness. Whatever it was, it completely undermined the whole piece. Successful humor is just not based on alternate universes. The punch-line to a joke can’t come from somewhere outside the setup. “Why did the chicken cross the road? Because the sky was green and there was no gravity.” The Lord God can’t just talk with an accent and then become Allah. The Lord God is Allah, and vice versa.

I had written a few related paragraphs about my thoughts on religion, evolution, intelligent design and a few other topics. Then I deleted them. If you really want to know what I think about any of those, buy me a beer. Or three, I’m difficult to pigeonhole and chatty when I drink.

ps. I will not acknowledge any guesses as right or wrong so please don’t bother.

Links for September 28, 2005

AppleScript System Events Bug

Despite the number of people successfully using my iPhoto AppleScripts, I’ve had a troubling number of people report problems as well. These weren’t just little problems, the scripts completely failed to run.

I asked several of these people to run the scripts from Script Editor and send me the error message they got when the scripts failed. All but one of the problems happened during a call to the System Events background application. Most infuriating was the fact that I couldn’t reproduce the problem. Today I managed to recreate what I believe is the problem.

The script below is a test script which pounds on System Events then tries to detect and recover from System Events crashes.

UIcheck() System Events Test Script (, 4k)

Please download the script and post your results in the comments. I’m seeing a consistent 3-9% failure rate for System Events on my PowerBook.

This is public domain, use at your own risk, etc. Please post improvements if you have them.

Update: Please post your OS version alongside any results.

Update 2: More on the System Events AppleScript bugginess Including a new test script.

Links for September 22, 2005

« Previous PageNext Page »