Apple Mail的非Top-Posting回复脚本

对于我想在iPhone上阅读的电子邮件帐户,我需要IMAP,所以我将这些帐户切换到Apple Mail多年来我一直在担心这一点。

我的第一个必须解决的烦恼是Mail的回复功能很难鼓励顶级发布,粗鲁和文盲的做法。

这是一个AppleScript,我通过删除每个响应顶部的空白行并将插入点移动到消息的底部来解决此问题(它使用GUI脚本,因此需要访问辅助设备要开启。)

tell application "Mail" to activate
tell application "System Events"
    tell process "Mail"
        tell menu bar 1
            click menu bar item "Message"'s menu "Message"'s ¬
                menu item "Reply"
        end tell
        delay 0.5
        key code 117 -- Forward Delete
        key code 125 using command down -- down arrow
        key code 36 -- Return
    end tell
end tell

以下是脚本的工作原理:

  1. 首先,手动调用Reply菜单项This creates a new message window with the quoted text of the message you’re responding to, with the insertion point at the beginning of a blank line at the top.

  2. 等一会儿没有这个延迟statement, the following lines sometimes fire before the new message window has been created and is ready to receive events.

  3. 送三个关键代码events: forward delete (to remove the blank line at the top); Command-DownArrow (to move the insertion point to the end of the message); and Return (to insert a blank line at the bottom).

我还创建了第二个版本的脚本来替换Mail的Reply All命令唯一的区别是改变菜单项“回复”菜单项“全部回复”

我保存了两个脚本〜/资源库/脚本/应用/邮件/我为他们分配了与Mail的内置命令相同的菜单键快捷键我用Red Sweater Software的FastScriptsto provide a system-wide scripts menu; when you assign a keyboard shortcut in FastScripts, FastScripts “sees” the shortcut before the current application does, which means that if a script has the same shortcut as a regular menu item — Command-R in the case of Mail’s Reply menu item — the script gets called, not the menu item.

换句话说,如果我手动选择消息→回复或单击Mail工具栏中的回复按钮,我仍然可以获得Mail的标准顶部发布样式响应要运行我的脚本,我使用Command-R快捷方式或从FastScripts菜单中选择脚本。

更新:签名

One shortcoming to this script is that it doesn’t quite work well with mail signatures; it’ll put the insertion point below your signature, rather than between the message and the signature这个问题没有发生在我身上,因为我早就习惯了TextExpander包括电子邮件签名,而不是Mailsmith(或现在的Mail)中的内置签名功能。

解决这个问题的一个简单方法是添加一些向上箭头关键代码126事件到脚本的结尾但是,如果使用具有不同行数的多个签名,则无效。