【发布时间】:2013-12-13 12:57:57
【问题描述】:
我使用此脚本在新选项卡中打开 URL,但我希望它改为在当前选项卡中打开。有没有办法做到这一点?
tell application "Firefox"
open location "http://www.yubnub.org"
end tell
【问题讨论】:
标签: firefox applescript
我使用此脚本在新选项卡中打开 URL,但我希望它改为在当前选项卡中打开。有没有办法做到这一点?
tell application "Firefox"
open location "http://www.yubnub.org"
end tell
【问题讨论】:
标签: firefox applescript
Firefox 的 Applescript 支持似乎不太存在。
使用系统事件和击键尝试此解决方法。
tell application "Firefox"
activate
set the clipboard to "http://www.yubnub.org"
tell application "System Events"
keystroke "l" using {command down}
keystroke "v" using {command down}
key code 36 -- return key
end tell
end tell
【讨论】:
我赞成接受的答案,这很好,并引导我找到我的解决方案,但是当您可以简单地通过键发送 URL 时,使用剪贴板输入 URL 似乎没有必要
tell application "Firefox"
activate
tell application "System Events"
keystroke "l" using {command down}
keystroke "http://www.yubnub.org"
key code 36 -- return key
end tell
end tell
行更短、更易于理解,并且不会产生覆盖剪贴板的不良副作用。
【讨论】: