Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos Mac:在Chrome或Firefox中重新加载文档?_Macos_Firefox_Google Chrome_Applescript - Fatal编程技术网

Macos Mac:在Chrome或Firefox中重新加载文档?

Macos Mac:在Chrome或Firefox中重新加载文档?,macos,firefox,google-chrome,applescript,Macos,Firefox,Google Chrome,Applescript,如何让Chrome或Firefox在顶部窗口中重新加载文档?以下是我在Safari中使用的: osascript -e ' tell application "Safari" activate do JavaScript "history.go(0)" in document 1 end tell ' 我认为Firefox或Chrome没有特殊的Applescript支持,但您可以发送击键(Cmd-R)来刷新页面: tell application "F

如何让Chrome或Firefox在顶部窗口中重新加载文档?以下是我在Safari中使用的:

osascript -e '
    tell application "Safari"
      activate
      do JavaScript "history.go(0)" in document 1
    end tell
'

我认为Firefox或Chrome没有特殊的Applescript支持,但您可以发送击键(Cmd-R)来刷新页面:

tell application "Firefox"
    activate
    tell application "System Events" to keystroke "r" using command down
end tell

下面是在Safari中不使用JavaScript的另一种方法:

tell application "Safari"
    tell its first document
        set its URL to (get its URL)
    end tell
end tell

以下是Chrome的代码:

tell application "Google Chrome"
    tell the active tab of its first window
        reload
    end tell
end tell
或者更简洁地说:

tell application "Google Chrome" to tell the active tab of its first window
    reload
end tell
自动机
  • 打开Automator并选择一个新文档
  • 选择服务

  • 将服务接收设置为无输入
  • 从操作列表中选择运行AppleScript操作
  • 在脚本中粘贴以下代码:

  • 保存服务,例如,使用Chrome Refresh的名称
系统首选项
  • 打开系统首选项>键盘
  • 在快捷方式选项卡中,选择服务
  • 指定一个新的快捷方式

Firefox本应如此,但目前的3.5.x版本显然已经破坏了它。漂亮!这适用于所有三种浏览器,使用“Firefox”、“Google Chrome”和“Safari”作为应用程序字符串。此脚本值得更多的升级,因为它不需要您在重新加载之前聚焦浏览器-这是关键。您也可以使用“first tab”而不是“active tab”
tell application "Google Chrome" to tell the active tab of its first window
reload
end tell