如何使用 AppleScript 编辑器在 Mac 上记录邮件 GUI 操作
我是 Mac 新手,正在尝试使用 AppleScript 来简化我的日常工作。我想要实现的目标之一是根据地址簿中的组自动创建智能邮箱。虽然我对自动化地址簿没有任何问题,但没有太多关于如何自动创建智能邮箱的文章。在网上进行一些搜索后,我意识到这只能通过 GUI 脚本来完成。但大多数答案都是关于如何打开新的智能邮箱对话框,但没有进一步的信息,例如如何选择不同的规则。我尝试使用 AppleScript Editor 来记录我的活动,以便从中学习,但在记录后发现,没有任何记录!我尝试使用其他应用程序(例如 Finder),录音确实有效!如果有人知道如何记录它,或者如何获取有关此类 GUI 脚本的更多信息,我们将不胜感激!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,Mail 的 Applescript 支持有时会因为如此的限制而令人抓狂。智能邮箱的控制只是一个例子。我本来希望 SL 能够解决这个问题,但苹果对 Applescript 的想法有时可能相当精神分裂。我不确定他们已经决定如何处理它。
我有一个智能邮箱创建脚本可以工作,但它从来没有可靠地工作过,所以我从未部署它。如果你真的想要它,我可以给你代码 - 尽管它是用 Python + Appscript 而不是纯 Applescript 编写的。
如果我是你,我会将此作为错误提交给 Apple,并希望 Lion 能够修复它。
我相信您已经发现 GUI 脚本的问题是弄清楚如何获取每个特定元素的名称可能会让人抓狂。有一些实用程序可以提供帮助,但除非您进行大量 GUI 脚本编写,否则它们可能不值得您付出代价。
关于 Applescript 录制,这是一个非常好的功能,通常在旧的 MacOS 下支持。然而,随着切换到 OSX,几乎没有应用程序支持它,因此对于所有实际意图而言,它基本上是一个死功能。
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.