UI Scripting - Timing?

I have been trying (with great frustration) to write a script to export all my albums from iPhoto into separate websites, one per album. iPhoto is really only partially scriptable, because you cannot perform an ‘export’ function… that requires the UI scripting approach, using System Events.

My problem is to do with timings. I have fought through the myriad button/window/tab/etc arrangements of iPhoto to get the right order of things, but now I find that system events just fire away, not waiting for the last to complete. While I can put timings in between windows opening, it isn’t easy to time the export.

Is there some way to have iPhoto message back to the script to say “I’m done exporting to a website” so that I can move to the next website and export it?

true, iPhoto has limited applescript dictionary, but there might be a way for you to get this automated.

For example:

tell application “iPhoto”
set numberOFphotos to count photos
end tell

If you can get the number of photos in the album, you might be able to roughly calculate the time it takes to do the export. This would probably work best if all the pictures are the same size/resolution in the album. But you could make a test album with 100 photos, export, timing it yourself to see how long it takes to export on your machine. Then just calculate the time per photo, and caress that into a script.

So after counting the photos in each album you open for export, just calculate the delay time you need, add a few extra seconds for safety and you should have a way to get there…

good luck.

One other thing – if you are going to do anything even semi serious with UI scripting, think hard about buying PreFab’s UI Browser. This is one sweet utility for UI scripting.

They do have a demo available which is fully functional for a while…