VisualStudio 2010 Post-Build事件刷新chrome选项卡



我有一个关于visual studio 2010后构建事件的问题。我有一个MVC3项目,我想要一个构建后的事件,使当前的chrome标签刷新。这可能吗?我有一个vb文件与此代码:

 set WshShell = WScript.CreateObject("WScript.Shell")
 WshShell.AppActivate "Google Chrome"
 WScript.Sleep 150
 WshShell.SendKeys "{f5}"

在vs2010的后构建事件命令行中,我有:

cscript c:test.vbs

但是这不会刷新页面,只会把焦点放在chrome上,但即使如此,如果我在焦点后按下键盘上的f5, chrome根本不会刷新。希望你能帮助我,谢谢!

以防你在8年后还在寻找解决方案。

在我的情况下,我想在构建我的解决方案后刷新我的网站,因为我的后构建事件将文件复制到我的网站文件夹。我用这个AutoHotkey脚本实现它:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
if WinExist("ahk_exe chrome.exe")
    WinActivate, ahk_exe chrome.exe
    Send {F5}

它最大化我的chrome窗口,并发送F5刷新屏幕。

当我安装AutoHotkey时,我选中了安装将脚本编译成可执行文件的工具的选项,我将其命名为RefreshSite.exe。这是通过右键单击我的脚本并单击编译脚本

来完成的

最后,我的post build事件是:

xcopy "MySource" "MyDesination" /s /y
start "" "C:ProjetsAutoHotkey ScriptsRefreshSite.exe"

这个解决方案并不完美,如果你的站点在另一个标签中,错误的标签将被刷新。它可能还可以改进,但对我来说已经足够好了。

最新更新