我正在尝试编写一个小的AppleScript,它将单击OneNote工具栏扩展,以便将其绑定到键盘快捷键。只要Safari实例处于窗口模式,下面的脚本即可正常运行,但在全屏模式下它将失败并返回错误:
错误“系统事件出错:无法获取进程\“ Safari \”的窗口1。索引无效。” 进程“ Safari”的窗口1中的编号-1719
我已将此脚本导出为应用程序,并授予了对该脚本的可访问性访问权限。实际上,似乎没有为全屏Safari窗口提供索引,或者不再是窗口,而现在是另一个对象。
tell application "System Events"
tell process "Safari"
click button whose description contains "OneNote" of toolbar 1 of window 1
end tell
end tell
MacBook Pro(Retina,13英寸,2013年末)OS X El Capitan,版本:10.11.6(15G1004)
试试这个脚本。无论Safari是否处于全屏模式,它都可以工作:
set myButton to "OneNote"
tell application "System Events"
tell process "Safari"
set isfullscreen to value of attribute "AXFullScreen" of window 1
if isfullscreen is true then
click ((buttons of toolbar 1 of group 1 of window 1) whose description contains myButton)
else
click ((buttons of toolbar 1 of window 1) whose description contains myButton)
end if
end tell
end tell
将“ OneNote”替换为您想要单击的任何按钮。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句