BATCH SCRIPT - Automating login to sites

3

I have the goal of creating a .bat file that automates my login to a particular site.

I can open the site with .bat via the start chrome.exe "myite.com" command, and I would like to know how to create a script that double-presses the TAB key and once the ENTER key.

Example of how I imagine it to be:

start chrome.exe "http://www.meusite.com"
teclado_automatico "{Alt}"
teclado_automatico "{Alt}"
teclado_automatico "{Enter}"
    
asked by anonymous 11.06.2015 / 16:43

3 answers

3

Another alternative would be to use tools like AutoIt or AutoHotKey which are automation languages for the Windows system and have several features to simulate a user interaction.

Follow the example using AutoIt :

#include <IE.au3>
' Abre o Internet Explorer
Local $oIE = _IECreate("www.meusite.com", 1)

' Aguarda o carregamento da página
_IELoadWait($oIE)

' Captura os elementos pelo id
Local $oUsuario = _IEGetObjById($oIE, "usuario")
Local $oSenha = _IEGetObjById($oIE, "senha")
Local $oBotao = _IEGetObjById($oIE, "btn")

' Define os valores
$oUsuario.value = "foo"
$oSenha.value = "bar"

' Simula um clique
_IEAction($oBotao, "click")
    
13.06.2015 / 22:28
2

An example in VBS, with internet explorer that you can adapt:

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.AppActivate "Internet Explorer"
Wscript.Sleep 1500
WshShell.SendKeys "{TAB}"
Wscript.Sleep 1500
WshShell.SendKeys "{TAB}"
Wscript.Sleep 1500
WshShell.SendKeys "{ENTER}"
Wscript.Sleep 1500
    
13.06.2015 / 19:19
1

I think the most appropriate solution to your problem of automation of tasks related to a browser is to use tools made exactly for this. One of the best known is iMacros. It has plugin for Chrome and Firefox.

iMacros also has its own programming language, and you can also use Javascript for automation. I used the company that worked to facilitate the entry of NFe (electronic invoices), while the integration with the ERP (via web service), had not been made.

Website: link

    
11.06.2015 / 18:52