【问题标题】:VisualStudio 2010 Post-Build event to refresh chrome tab?Visual Studio 2010 Post-Build 事件刷新 chrome 选项卡?
【发布时间】:2011-12-16 10:51:53
【问题描述】:

我对 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 根本不会刷新。 希望您能帮帮我,谢谢!

【问题讨论】:

    标签: visual-studio-2010 post-build-event


    【解决方案1】:

    以防万一您在 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。这是通过右键单击我的脚本并单击编译脚本

    来完成的

    最后,我的后期构建事件是:

    xcopy "MySource" "MyDesination" /s /y
    start "" "C:\Projets\AutoHotkey Scripts\RefreshSite.exe"
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 2011-08-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多