How to refresh only a particular tab in DEFAULT browser, other tabs should not refresh

My default browser is launched when a batch calls this VB Script and refreshes as the application does not open instantly and needs refresh. But it is refreshing all the tabs. I want the particular tab to get refreshed with this particular URL and once the application is  open the refresh operation should stop. can it be done within this VB script.

My code:  

Option Explicit
      Dim myowmObj
      Dim ObservedPort
      Dim Counter
    Set myowmObj=WScript.CreateObject("WScript.Shell")
    ObservedPort = WScript.Arguments(0)
    myowmObj.Run "http://localhost:"&port&"/HatsDemo"
      'Wait for 3 seconds
      Wscript.Sleep 3000
      Counter = 20
      Do While Counter > 0
            Counter = Counter - 1
            'Send the F5 key for a refresh
            myowmObj.SendKeys "{F5}"
            'Wait for 2 seconds
            Wscript.Sleep 2000
Aryabhatta MAsked:
Who is Participating?
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
How would you be able to know that the page is now complete? Unless you can see that in the window title, I don't see any way.
AppActivate returns a boolean result, telling if the window title has been found. If the title changes as soon as the page is completed, and is different enough the AppActivate won't find it anymore, you are done. Just check the result, and only if true issue the SendKeys and continue the loop.
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
As I said in your other question,, it is very unreliable to use SendKeys, in particular for repeated key strokes and delays.

Whatsoever, F5 in all browsers I know just refreshes the current tab.

The next request is not feasible with your approach at all. You just spawn a new browser tab, and do not have any relation to it in VBS after doing so. Hence you have nought control over it.
You can use indirect measures, like checking windows titles for something specific only appearing if the "application is open" (whatever that means). But again, since indirect and depends on the browser's behaviour about setting windows titles, it is unreliable.

The way I showed in the other question puts some restrictions in (it forces use of IE), but that is the only way to get enough control over a browser.
Aryabhatta MAuthor Commented:
While the iterative refresh goes on if you click another tab and open in monitor it will refresh that page too. If desktop is open it will refresh desktop :-)
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

QlemoBatchelor, Developer and EE Topic AdvisorCommented:
As I mentioned, that is the price to pay for the indirect approach. You would have to write your own JavaScript code doing the start + refresh + checks etc, and run that instead of your URL. Or use what I have shown in the other question, using a IE object.
With your current approach, the only improvement you can try is to explicitly activate the window you want to address. That works if there is unique windows title. You just run
myowmObj.AppActivate title

Open in new window

immediately before using SendKeys, where title identifies the head part of the window title. If non-unique, the first found will be activated, so make sure to be as specific as possible.
Aryabhatta MAuthor Commented:
Can I atleast stop the refresh once it loads the page ?
Aryabhatta MAuthor Commented:
I added AppActicvate before Run statement. But same effect. Seems not possible to do.
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You need to place it before  myowmObj.SendKeys "{F5}". Having it before Run won't have any effect, of course.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.