有时您需要一次完成每个过程,以隔离产生错误的原因。首先让我们看看这段代码是否会选择橡皮擦工具。
将以下 AppleScript 代码粘贴到新的 Script Editor.app 文档中。您可以直接从该文档运行代码。如果代码适合您,则尝试将其粘贴到您的 Automator 工作流程中。
tell application "Microsoft PowerPoint"
activate
repeat until frontmost
delay 0.1
end repeat
end tell
tell application "System Events"
repeat while not (exists of radio button 3 of tab group 1 of window 1 of application process "PowerPoint")
delay 0.1
end repeat
if not (exists of menu button "Eraser" of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint") then
click radio button 3 of tab group 1 of window 1 of application process "PowerPoint"
delay 0.1
if value of menu button 1 of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint" is 0 then
click menu button "Eraser" of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint"
end if
else
delay 0.1
if value of menu button 1 of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint" is 0 then
click menu button "Eraser" of group 1 of scroll area 1 of tab group 1 of window 1 of application process "PowerPoint"
end if
end if
end tell

确保将 Automator.app、Script Editor.app、System Events.app 和 PowerPoint.app... 以及脚本(如果它保存为 .app)添加到 System Preferences > Security > Privacy > Accessibility 应用程序列表. 然后再次将这些相同的项目添加到系统偏好设置 > 安全 > 隐私 > 全盘访问应用程序列表。

此外,如果您将脚本或 Automator 工作流程保存为应用程序,则无论何时您进行更改并再次保存该文件,您都需要返回并再次将其重新添加到安全首选项中的这些应用程序列表中。