【问题标题】:Open URL in current tab in Firefox via Applescript通过 Applescript 在 Firefox 的当前选项卡中打开 URL
【发布时间】:2013-12-13 12:57:57
【问题描述】:

我使用此脚本在新选项卡中打开 URL,但我希望它改为在当前选项卡中打开。有没有办法做到这一点?

tell application "Firefox"
    open location "http://www.yubnub.org"
end tell

【问题讨论】:

    标签: firefox applescript


    【解决方案1】:

    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
    

    【讨论】:

    • 谢谢。它奏效了,这正是我想要做的。
    【解决方案2】:

    我赞成接受的答案,这很好,并引导我找到我的解决方案,但是当您可以简单地通过键发送 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
    

    行更短、更易于理解,并且不会产生覆盖剪贴板的不良副作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多