我需要在Safari中执行自动安装扩展。如何通过AppleScript在Safari中安装扩展程序
现在我有这部分代码:
property extension_list : {"safariextz"}
on adding folder items to this_folder after receiving these_items
try
tell application "Finder"
repeat with i from 1 to (number of items in these_items)
set this_item to item i of these_items
set item_extension to name extension of this_item
if item_extension = "safariextz" then
tell application "Safari" to open this_item
delete this_item
end if
end repeat
end tell
on error errmsg
display dialog errmsg buttons {"OK"} default button 1
end try
end adding folder items to
这工作,文件下载后运行。 但我无法按开始安装扩展按钮安装。
我想类似的东西
tell application "System Events"
tell process "Safari"
click the button "Install"
end tell
end tell
但是,这并没有帮助。 云你请帮我完成扩展安装的脚本?
谢谢您的帮助! 我检查了辅助功能检查器中的按钮,它的编号为3. 所以我更新了这一行:单击前窗的按钮3 - 安装 但不幸的是,这并没有帮助,我仍然没有按脚本按钮。 我一直在等待约1分钟,然后显示“Safari出错:AppleEvent超时”。 它可能与忽略过程有关吗?在我的脚本中可能会出现错误,并且在代码之后不会继续:将应用程序“Safari”打开以打开this_item – Ellina
“GUI脚本”取决于操作系统和Safari的版本。 我的脚本适用于Safari 7.0.5和OS X 10.9.4 – jackjr300
在这里,我只有两个按钮在这个窗口中。试试这个:在'tell process'之后添加'set frontmost to true'Safari'' – jackjr300