Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

.vbs set focus on opened firefox window or open a new firefox session

$
0
0
Hello,

I want to set the focus to the opened Firefox window.

This code ist not working for me, it's opening a new firefox window, what I don't want to:
Code:

Dim ws
    Set ws = Wscript.CreateObject("Wscript.Shell")
    ws.Run("Firefox.exe"),1,False
    Do Until Success = True
    Success = Act.AppActivate("Firefox")
    Wscript.Sleep 1000
    Loop
    Wscript.Sleep 1000
    ws.sendkeys "^l"
    ws.sendkeys "https://google.de"
    ws.SendKeys "{ENTER}"
    Set wshshell = Nothing
    wscript.quit

This code is not working:

Code:

  dim ws
    Set ws = WScript.CreateObject("WScript.Shell")
    ws.run """C:\Program Files\Mozilla Firefox\firefox.exe"" ,1,False
    Wscript.Sleep 1000
    ws.sendkeys "^l"
    ws.sendkeys "https://google.de"
    ws.SendKeys "{ENTER}"
    Set ws = Nothing
    wscript.quit

The both codes don't do what I want to have.
That is what I want:
I start .vbs, Firefox opens, if it isn't already opened, if a Firefox window is opened, the focus should be on the opened Firefox window and it shouldn't open a new window.


Thank you very much for your help.

Best regards,
Dani

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>