Script help (Auto login)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zombiekittens
Posts: 1
Joined: 08 Oct 2013, 08:21

Script help (Auto login)

Post by zombiekittens » 08 Oct 2013, 08:22

I have a display monitor in a school that rotates through some web pages that displays current building usage. The Monitor has a small form computer mounted to the back of it to get internet access. There cannot be a keyboard or mouse attached because we need to keep people from messing with it. I want the computer to bootup, open IE, go to an IP address and enter the Username and Password, Send the U/P - Which will open and display the rotating script (Pages) -. I was thinking I could use AutoHotKey to start IE and log into with the Username/Password, and use a Startup Bat file to start the Autokey Script on Startup. I tried different examples from the site on auto logins and I can get it to start IE and go the Webpage page but I can get it to fill the User Name and Password fields in. If someone could show me how to achieve this I would be very grateful. And if you have a better suggestion than the way I am going about this please let me know.




Thanks for any help,

M.



Here is the part of the script that has the login fields from the page I am trying to log into.








</td>
</tr>
<tr>
<td align="left" style="width: 40%">
<span id="ctl00_OWSMasterPlaceholder_lblUserID" class="ContentHeading" key="LoginPage.lblUserID">User ID*</span>
</td>
<td>
<input name="ctl00$OWSMasterPlaceholder$txtUserName" type="text" maxlength="32" id="ctl00_OWSMasterPlaceholder_txtUserName" tabindex="1" class="InputFieldStyle" />
<span id="ctl00_OWSMasterPlaceholder_lblErrorUserName" class="ErrorMark"></span>
</td>
</tr>

<tr>
<td align="left" style="width: 40%">
<span id="ctl00_OWSMasterPlaceholder_lblPassword" class="ContentHeading" key="LoginPage.lblPassword">Password*</span>
</td>
<td>
<input name="ctl00$OWSMasterPlaceholder$txtPassword" type="password" maxlength="32" id="ctl00_OWSMasterPlaceholder_txtPassword" tabindex="2" class="InputFieldStyle" />
<span id="ctl00_OWSMasterPlaceholder_lblErrorPassword" class="ErrorMark"></span>
</td>
</tr>

<tr>
<td class="ContentToButtonsBreak" colspan="2">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="ctl00$OWSMasterPlaceholder$btnOk" value="Log in" onclick="return fnValidateForm();" id="ctl00_OWSMasterPlaceholder_btnOk" tabindex="5" class="AdjacentButtons" key="LoginPage.btnSubmit" />
</td>

User avatar
Pulover
Posts: 612
Joined: 29 Sep 2013, 19:51
Location: Brazil
Contact:

Re: Script help (Auto login)

Post by Pulover » 08 Oct 2013, 08:39

Hi M,

You should have included the form but you can also use the button. Try this code for the login (untested).
Fill the variables at the beginning.

Code: Select all

SiteAddress := "IPAddressHere"
Username := "UserNameHere"
Password := "PasswordHere"

ie := ComObjCreate("InternetExplorer.Application")
ie.Visible := true
ie.Navigate(SiteAddress)
IELoad(ie)
ie.document.getElementsByName("ctl00$OWSMasterPlaceholder$txtUserName")[0].Value := Username
ie.document.getElementsByName("ctl00$OWSMasterPlaceholder$txtPassword")[0].Value := Password
ie.document.getElementsByName("ctl00$OWSMasterPlaceholder$btnOk")[0].Click()
return

IELoad(Pwb)
{
	If !Pwb
		Return False
	While !(Pwb.busy)
		Sleep, 100
	While (Pwb.busy)
		Sleep, 100
	While !(Pwb.document.Readystate = "Complete")
		Sleep, 100
	Return True
}
Rodolfo U. Batista
Pulover's Macro Creator - Automation Tool (Recorder & Script Writer)

Post Reply

Return to “Ask for Help (v1)”