VisualStudio 2010 构建后事件刷新 chrome 选项卡?

发布于 2024-12-12 05:12:47 字数 429 浏览 0 评论 0原文

我对 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我的键盘在焦点后,镀铬根本不刷新。 我希望你能帮助我,谢谢!

i have a question about post-build events in visual studio 2010.
I have an MVC3 project and i want a post-build event that make a refresh on the current chrome tab. It's that possible?
What i have is a vb file with this code:

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

And in the post-build event command line of vs2010 i have:

cscript c:\test.vbs

But this doesn't refresh the page, only put on focus the chrome, but even so, if i hit f5 on my keyboard after the focus, the chrome doesn't refresh at all.
I hope you can help me, thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日情怀 2024-12-19 05:12:47

以防万一 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"

此解决方案并不完美,如果您的网站位于另一个选项卡中,则会刷新错误的选项卡。它可能还有待改进,但对我来说已经足够好了。

Just in case you are still looking for a solution 8 years later.

In my case I wanted to refresh my website after building my solution since my post-build event copies files to my website folder. I achieve it with this AutoHotkey script :

#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}

It maximizes my chrome window and send F5 to refresh the screen.

When I installed AutoHotkey, I checked the option to install the tool that compiles your script in an executable, which I named RefreshSite.exe. This was done by right-clicking my script and clicking on Compile Script

Finally, my post build event is :

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

This solution isn't perfect, if your site is in another tab, the wrong tab will get refreshed. It can probably be improved but was good enough for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文