macos - 为什么我在 AppleScript 命令中的击键不能将打开的电子邮件信息变成“外发”信息?
问题描述
我正在尝试实现一个 AppleScript 来查找邮箱中保存的外发电子邮件草稿的电子邮件。然后应该打开在那里找到的每一个, ,变成一个传出消息,然后发送。我已经非常接近了,但是在下面的脚本中,击键命令什么都不做。它应该通过调用“再次发送”将消息转换为传出消息。
using terms from application "Mail"
tell application "Mail"
set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
set foundMsgs to (every message in theMailbox)
set the messageCount to the count of foundMsgs
repeat with i from 1 to the messageCount
set newMsg to item i of foundMsgs
tell newMsg
open
tell application "System Events"
tell application process "Mail"
keystroke "D" using {shift down, command down}
end tell
end tell
end tell
end repeat
end tell
end using terms from
但它什么也没做。消息已打开,但击键无效。下一步是发送消息,但脚本中没有显示。
解决方案
我认为您不需要使用“使用邮件中的条款”命令,因为您在下一行有一个邮件通知块。
试试这段代码,看看它是否有效。
tell application "Mail"
set theMailbox to mailbox "OutgoingEmail" of account "iCloud"
set foundMsgs to (every message in theMailbox)
set the messageCount to the count of foundMsgs
repeat with i from 1 to the messageCount
set newMsg to item i of foundMsgs
tell newMsg
open
end tell
tell application "System Events"
tell application process "Mail"
keystroke "D" using {shift down, command down}
end tell
end tell
end repeat
end tell
还可以尝试仅包含系统事件命令的单独脚本,以查看它们是否单独工作...
tell application "System Events"
tell application process "Mail"
keystroke "D" using {shift down, command down}
end tell
end tell
推荐阅读
- apache-spark - 将数据从 Spark 结构化流加载到 ArrayList
- spring-boot - Spring Boot 应用程序中的 Swagger2 不会使用自定义 Docket 获取 @ApiResponses
- django - Django迁移删除和更新
- linux - 如何在 ubuntu 上的 /var/www 中创建目录?设置权限
- visual-studio - MDX 查询在 SSMS 中有效,但在 Visual Studio 中无效
- c# - 从控制器检索数据并返回 ajax 调用失败
- jquery - 单击菜单容器外部时如何关闭下拉菜单?
- android - Android 游戏和其他基于引擎的复杂应用程序如何通过 - 或以其他方式处理 - 进程死亡来保持状态?
- loops - SAS 宏执行循环问题
- sas - 包含两个宏变量的 SAS 宏变量未解析