0
votes

I'm a newbie to Mac and trying to use AppleScript to ease my daily job. One of the things I want to achieve is to automatically create Smart Mailbox based on the groups in my Address Book. While I have no problem automate Address Book, there's no much article about how to automatically create Smart Mailbox. After some searches on the web I realized it can only be done through GUI scripting. But most of the answers are about how to bring up the new Smart Mailbox dialog but no further information about e.g. how to select different rules. I tried to use AppleScript Editor to record my activity so that I can learn from that but found out after recording, there's nothing get recorded! I tried with other apps like Finder the recording does work! If anyone knows how to record it, or how to get more information on this type of GUI scripting would be very appreciated!

1
I'm not sure of the answer to your whole question off the top of my head, but the reason that recording in AppleScript Editor didn't work is that being able to record things relies on that application exposing a way to AppleScript it. If you can't AppleScript it, you can't record it.Antal Spector-Zabusky

1 Answers

2
votes

Unfortunately Mail's Applescript support is more than a little maddening at times due to being so limited. Control of smart mailboxes is but one example. I'd hoped SL would have fixed this but Apple's thinking about Applescript can be pretty schizophrenic at times. I'm not sure they have decided what to do with it.

I'd got a Smart Mailbox creation script working but it never worked reliably so I never deployed it. If you really want it I can give you the code - although it's written in Python + Appscript rather than pure Applescript.

Were I you I'd submit this as a bug to Apple and hopefully it'll be fixed with Lion.

The problem with GUI scripting as I'm sure you discovered is that figuring out how to get the name of each particular element can be maddening. There are a few utilities out there that will help, but unless you are doing a lot of GUI scripting they probably aren't worth the cost.

Regarding Applescript recording this was a really nice feature often supported under the old MacOS. However with the switch to OSX almost no application supports it so it's basically a dead feature for all practical intents.