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
      Loop
Aryabhatta MAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
As I said in your other question, https://www.experts-exchange.com/questions/29072404/In-a-Batch-script-how-to-refresh-webpage-after-launching-in-default-browser.html, 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.
0
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 :-)
0
Qlemo"Batchelor", 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.
0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Aryabhatta MAuthor Commented:
Can I atleast stop the refresh once it loads the page ?
0
Qlemo"Batchelor", 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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aryabhatta MAuthor Commented:
I added AppActicvate before Run statement. But same effect. Seems not possible to do.
0
Qlemo"Batchelor", 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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.