Automatic login to a website on windows 7/Chrome via batch file

后端 未结 2 1601
醉梦人生
醉梦人生 2020-12-10 05:47

I have a batch file. I have case select. if user types 26 it will open link 1 chrome. if user types 27 it will open link 2 in chrome.

But I still can\'t figure out,

2条回答
  •  庸人自扰
    2020-12-10 06:10

    You can try the following code:

    set WshShell = WScript.CreateObject("WScript.Shell")
    call WshShell.Run("http://www.gmail.com", 1, false) 'This will open your default browser
    
    WScript.Sleep 2000
    WshShell.SendKeys "username"
    WScript.Sleep 1000
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 1000
    WshShell.SendKeys "password"
    WshShell.SendKeys "{TAB}"
    WScript.Sleep 1000
    WshShell.SendKeys "{ENTER}"
    WScript.Quit()
    

    The code opens your browser, waits for the page to load, and then enters the username and password assuming that the cursor is in the right input box (for example, in Gmail, it will be on the username input box). Else you have to navigate to the right input box by using TAB.

    If you are against writing the password in the script file, save it on you browser and use the appropriate SendKeys method for logging in.

提交回复
热议问题