我为被调用的应用程序制作了一个applescript。但我有一个异常问题:(
抱歉,但是“您需要至少 10 个声望才能发布图片。”
我的问题在哪里?
tell application "System Events" to tell process "EndpointConnect"
tell menu bar item 1 of menu bar 2
click
click menu item "Disconnect" of menu 1
end tell
end tell
实际结果是:
error "System Events got an error: Can’t get menu 1 of menu bar item 1 of menu bar 2 of process \"EndpointConnect\". Invalid index." number -1719 from menu 1 of menu bar item 1 of menu bar 2 of process "EndpointConnect"
目前的脚本click
在(尚)不存在的对象上执行 a 。基本上,您需要delay
在两个click
命令之间给系统时间来实例化菜单及其项目。
这是我无法为您测试的编辑,但我希望能奏效:
tell application "System Events" to tell ¬
process "EndpointConnect" to tell ¬
menu bar 2 to tell ¬
menu bar item 1
if not (exists) then return null
click
tell (a reference to menu item "Disconnect" of menu 1)
repeat until it exists
delay 0.5
end repeat
click
end tell
end tell
但是,由于某些未知原因,您可能会在菜单出现和单击菜单项之间出现令人讨厌的 5 秒延迟。这是众所周知的/记录在案的,经常被抱怨的,并且是一个多年未解决的问题,而且可能永远不会解决。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句