我写了一个简单的代码来点击Notes应用程序上的分享按钮
set upArrow to ASCII character 30
activate application "Notes"
tell application "System Events"
tell process "Notes"
set frontmost to true
click button 2 of group 2 of splitter group of window 1
keystroke upArrow
keystroke return
end tell
end tell
问题是
click button 2 of group 2 of splitter group 1 of window 1 of application process "Notes" --> missing value
完成此操作需要6s并返回错误缺失值
但如果我不添加击键或任何命令,则此代码完美地运行
答案 0 :(得分:1)
我也得到了延迟并且它返回了缺失值。但是你可以点击菜单栏项吗?
activate application "Notes"
tell application "System Events" to tell process "Notes"
click menu item "Email" of menu 1 of menu item "Share" of menu "File" of menu bar 1
end tell
答案 1 :(得分:0)
有一个线程似乎描述了似乎仅限于特定软件的相同错误。它位于MacScripter.net上:Script delays on clicking button (controlling Sys Prefs pane)
请注意描述FileMaker延迟的最新帖子。当软件出现这个错误时,似乎唯一的解决办法就是做其他事情来打开新窗口。如果运行所需功能的唯一方法是通过按钮,则一个(可怕的)选项是在相对于前窗角落的坐标处单击。显然,如果内容可以相对于角落移动或者如果新版本的软件移动所需的按钮,则这很容易失败。还有其他想法吗?
答案 2 :(得分:0)
set focused of button 2 of group 2 of splitter group 1 of window 1 to true
keystroke space
或
set value of attribute "AXFocused" of button 2 of group 2 of splitter group 1 of window 1 to true
keystroke space
来源:
https://lists.apple.com/archives/Accessibility-dev/2006/Oct/msg00013.html