每当调用 bat 文件时,我都会尝试刷新 Firefox。我不想要延期。我需要知道是否有可以从 .bat 文件中使用的命令来重新加载当前浏览器或选项卡。
我知道你可以使用start firefox
作为一个命令,但这只是打开一个新的 Firefox 实例。我需要刷新当前实例。
我只是闲逛,想出了这个半工作的解决方案,可能会有所帮助。创建一个名为类似的文件refresh.vbs
并将其粘贴到:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate("Google Chrome")
WScript.Sleep 500
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{F5}"
I could only test it with Chrome. The script activates Chrome, sends a tab, and then sends F5 to refresh. It works when I have Chrome up showing one web page, but not when there are multiple web tabs open (because AppActivate activates the Window, but does not give focus to anything).
也许用 Firefox 效果更好。可能有某种方法可以枚举浏览器中的选项卡并在 vbs 中激活它,但我不知道。
如果您在 vbs 中生成浏览器(请参阅WshShell.运行,以及中的示例SendKeys文档),您可以获取进程号并将消息直接发送到该窗口,而不是依赖应用程序标题。
如果需要,您可以从批处理文件中调用 .vbs:
@echo off
refresh.vbs
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)