4

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!

Phoenix_uy
  • 3,173
  • 9
  • 53
  • 100

1 Answers1

0

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.

Simon ML
  • 1,819
  • 2
  • 14
  • 32