用automator+applescript解决方案
我找到的解决方案是创建一个自动机服务,并有选择地将其与快捷方式相关联。
-
打开自动机。
-
新文件。
-
选择
Service
对于文档类型。
-
在窗口顶部,设置此服务的输入类型:
Service receives selected
选择
no input
in
选择
Mail.app
-
在操作库(左窗格)中找到操作
Run AppleScript
.
-
在工作流区域中拖放它。
-
复制此答案末尾的代码并将其粘贴到操作中
运行applescript
是的。
-
保存您的服务(例如“跳转到文件夹”)。
测试服务
测试服务时,automator可以保持打开状态,也可以保持邮件应用程序的打开状态。
-
打开邮件应用程序。
-
执行搜索并选择一条消息,最好是位于自定义文件夹中的消息。
-
在菜单栏中转到
Mail
gt;
Services
.你应该看看你的新服务。
-
选择服务。
所选且活动的邮箱/文件夹应是以前所选邮件的邮箱。
可选。为您的服务指定快捷方式:
-
打开系统首选项。
-
去
Keyboard
>
Shortcuts
-
在左窗格中选择
服务
-
在右窗格的末尾
General
你应该找到你的服务
-
为它指定一个快捷方式(例如
命令
-
选择权
-
J
)
守则
set theDialogTitle to "Go to Folder Script"
tell application "Mail"
-- Get the selected messages and the count of them
set theMessageList to selected messages of message viewer 1
set theCount to length of theMessageList
-- Error if no messages
if theCount is 0 then
display dialog ¬
"No message selected." with title theDialogTitle buttons {"OK"} with icon caution
return
end if
-- Error if more than one message
if theCount is greater than 1 then
display dialog ¬
"Must select only one message." with title theDialogTitle buttons {"OK"} with icon caution
return
end if
-- Get the message
set theMessage to item 1 of theMessageList
-- Get the mailbox object
set theMailbox to mailbox of theMessage
-- Select the mailbox
set selected mailboxes of message viewer 1 to theMailbox
end tell