Batch file that changes URL in open browser

后端 未结 2 699
北荒
北荒 2021-01-07 08:25

I\'ve seen something like this:

start /d \"C:\\Program Files\\Internet Explorer (x86)\\IEXPLORE.EXE\" www.google.com

But this just opens a

相关标签:
2条回答
  • 2021-01-07 09:01

    You may use SendKeys directly in your Batch file, as shown in this or this or this answer; for example:

    @if (@CodeSection == @Batch) @then
    
    @echo off
    
    rem Start default IE
    start /d "C:\Program Files\Internet Explorer (x86)\IEXPLORE.EXE" www.google.com
    
    :changeLoop
    CScript //nologo //E:JScript "%~F0" "keys to change to first webpage"
    timeout /T 10
    CScript //nologo //E:JScript "%~F0" "keys to change to second webpage"
    timeout /T 10
    goto changeLoop
    
    @end
    
    WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));
    
    0 讨论(0)
  • 2021-01-07 09:14

    You should be able to do this using SendKeys, see here.

    Basically, you look at the dropdown menus of Internet Explorer (i.e. File, Edit etc) and look at the shortcut keys for what you would want to do, then you write a little bit of VBscript to send those keystrokes. You save the VBscript in a file with the ".VBS" extension and then you can just double-click it to run it. Something like this should get you started....

     set WshShell = WScript.CreateObject("WScript.Shell")
     WshShell.Run "iexplore"
     WScript.Sleep 500
     WshShell.AppActivate "Windows Internet Explorer"
     WshShell.SendKeys "www.google.com"
    

    If you have already started IE using your own START command, you can just send the keystrokes you need to control it after that and you will not need the WshShell.Run part I have.

    0 讨论(0)
提交回复
热议问题