How to automate a Web-Login ? (Requires IE)
http://www.autohotke...p?p=67646#67646
I am posting here an experimental script I wrote for automating AHK-Forum Login.
Alter the first three variables correctly to get working resultsUserName=ahkuser PassWord=ahkuser IExplore=C:\Program Files\Internet Explorer\iexplore.exe TempFile=%A_Temp%\AHK-F.htm MemVar= ( Join <head>`n<title>AHK.Automated.Login.AHK-Forum</title>`n</head>`n<bodyùbgcolor="#E 5E5E5"ùtext="#000000"ùlink="#006699"ùvlink="#5493B4"ùleftmargin="15"ùtopmargin=" 5"ùmarginwidth="5"ùmarginheight="5">`n<aùname="top"></a>ù`n<tableùwidth="300"ùce llspacing="0"ùcellpadding="0"ùborder="0"ùalign="left">`nø<tr>ù`nö<tdùclass="body line"ùheight="134">ù`nô<formùaction="http://www.autohotkey.com/forum/login.php?s id="ùmethod="post"ùtarget="_top">`nò<tableùwidth="100`%"ùcellpadding="0"ùcellspa cing="0"ùborder="0"ùclass="forumline"ùalign="center">`nñù<tr>ù`nñ÷<tdùclass="row 1">ù`nñõ<tableùborder="0"ùcellpadding="2"ùcellspacing="2"ùwidth="100`%">`nñó<tr> ù`nññ<tdùwidth="70`%">ù`nññø<inputùtype="text"ùclass="post"ùname="username"ùvalu e="u.s.e.r.n.a.m.e"ùsize="25"ùmaxlength="40"ù/>`nññ</td>`nñó</tr>`nñó<tr>ù`nññ<t dùwidth="70`%">ù`nññø<inputùtype="password"ùvalue="p.a.s.s.w.o.r.d"ùclass="post" ùname="password"ùsize="25"ùmaxlength="32"ù/>`nññ</td>`nñó</tr>`nñó<trùalign="cen ter">ù`nññ<td>ù`nññø<divùalign="left"><spanùclass="gen">ù`nññö<inputùtype="check box"ùcheckedùname="autologin"ù/>`nññö</span>ù`nññö<inputùtype="hidden"ùname="red irect"ùvalue=""ù/>`nññö<inputùtype="submit"ùname="login"ùclass="mainoption"ùvalu e="Logùin"ù/>`nññø</div>`nññ</td>`nñó</tr>`nñõ</table>`nñ÷</td>`nñù</tr>`nò</tab le>`nô</form>`nô<divùalign="center"></div>`nö</td>`nø</tr>`n</table>`n</body>`n< /html> ) MemVar:=ExpandSpaces(MemVar) ; uncompress the spaces StringReplace, MemVar, MemVar, u.s.e.r.n.a.m.e, %UserName% StringReplace, MemVar, MemVar, p.a.s.s.w.o.r.d, %PassWord% FileErase(TempFile) FileAppend, % MemVar, %TempFile% MemVar= Run, %IExplore% "%TempFile%", , MAX WinWaitActive, AHK.Automated.Login.AHK-Forum IEID1:=WinExist("AHK.Automated.Login.AHK-Forum") ControlSend, Internet Explorer_Server1, {Tab 5}{Enter}, ahk_id %IEID1% Sleep, 2000 FileErase(TempFile) Return ExpandSpaces(MemVar,Asc=240) { Loop, 9 StringReplace, MemVar, MemVar, % Chr(Asc+A_Index), % Space(10-a_Index), All Return MemVar } Space(Width) { Loop,%Width% Space=% Space Chr(32) Return Space } FileErase(FileName) { ;Thanks to PhiLho: http://www.autohotkey.com/forum/viewtopic.php?p=52564#52564 handle:=DllCall("CreateFile", "Str",FileName, "UInt",0x40000000 ,"UInt",3 , "UInt",0 , "UInt",5 , "UInt",0 , "UInt",0) DllCall("CloseHandle", "UInt", handle) FileRecycle, %FileName% ; Change this to: FileDelete, %FileName% IfLessOrEqual, handle, 0, Return, 0 Return 1 }
Right click & save this file: ahkloginhtml.txt.txt to see the actual HTML
I will post the text compression technique (used for encoding the HTML text) in a seperate topic.
Meanwhile, let me know if someone wants a similar auto-login script for GMail.
Regards,
[How to] Automate a Web-Login (Requires IE)
#1
Posted 11 July 2006 - 02:25 PM
#2
RedCairo
Posted 21 October 2011 - 01:21 PM
I really would like the other script you mentioned, to automate Gmail login. And ideally just something I could customize to work out login on anything (I assume there are tab indexes or mouse click locations or something custom to each).
I am brand new to AHK so still basically an idiot, but the web login and gmail login were early on my list of ideal things to start with. :-)
Thanks!
Palyne
#3
Posted 21 October 2011 - 01:35 PM
Welcome to the forum RedCairo. You can use this;I really would like... ...to automate Gmail login.
GMailLogIn("[color=red]WriteYourUserNameHere[/color]","[color=red]WriteYourPasswordHere[/color]")
GMailLogIn(UserName,Password) {
pwb := ComObjCreate( "InternetExplorer.Application")
pwb.Visible := True
pwb.Navigate( "http://mail.google.com/mail")
While, (pwb.ReadyState <> 4)
Sleep, 100
pwb.document.all.Email.value := UserName
pwb.document.all.Passwd.value := Password
pwb.document.all.signIn.click
}
#4
RedCairo
Posted 29 October 2011 - 10:43 AM
#5
Posted 27 November 2011 - 06:41 PM
How to automate a Web-Login ? (Requires IE)
http://www.autohotke...p?p=67646#67646
I am posting here an experimental script I wrote for automating AHK-Forum Login.
Alter the first three variables correctly to get working resultsUserName=ahkuser PassWord=ahkuser IExplore=C:\Program Files\Internet Explorer\iexplore.exe TempFile=%A_Temp%\AHK-F.htm MemVar= ( Join <head>`n<title>AHK.Automated.Login.AHK-Forum</title>`n</head>`n<bodyùbgcolor="#E 5E5E5"ùtext="#000000"ùlink="#006699"ùvlink="#5493B4"ùleftmargin="15"ùtopmargin=" 5"ùmarginwidth="5"ùmarginheight="5">`n<aùname="top"></a>ù`n<tableùwidth="300"ùce llspacing="0"ùcellpadding="0"ùborder="0"ùalign="left">`nø<tr>ù`nö<tdùclass="body line"ùheight="134">ù`nô<formùaction="http://www.autohotkey.com/forum/login.php?s id="ùmethod="post"ùtarget="_top">`nò<tableùwidth="100`%"ùcellpadding="0"ùcellspa cing="0"ùborder="0"ùclass="forumline"ùalign="center">`nñù<tr>ù`nñ÷<tdùclass="row 1">ù`nñõ<tableùborder="0"ùcellpadding="2"ùcellspacing="2"ùwidth="100`%">`nñó<tr> ù`nññ<tdùwidth="70`%">ù`nññø<inputùtype="text"ùclass="post"ùname="username"ùvalu e="u.s.e.r.n.a.m.e"ùsize="25"ùmaxlength="40"ù/>`nññ</td>`nñó</tr>`nñó<tr>ù`nññ<t dùwidth="70`%">ù`nññø<inputùtype="password"ùvalue="p.a.s.s.w.o.r.d"ùclass="post" ùname="password"ùsize="25"ùmaxlength="32"ù/>`nññ</td>`nñó</tr>`nñó<trùalign="cen ter">ù`nññ<td>ù`nññø<divùalign="left"><spanùclass="gen">ù`nññö<inputùtype="check box"ùcheckedùname="autologin"ù/>`nññö</span>ù`nññö<inputùtype="hidden"ùname="red irect"ùvalue=""ù/>`nññö<inputùtype="submit"ùname="login"ùclass="mainoption"ùvalu e="Logùin"ù/>`nññø</div>`nññ</td>`nñó</tr>`nñõ</table>`nñ÷</td>`nñù</tr>`nò</tab le>`nô</form>`nô<divùalign="center"></div>`nö</td>`nø</tr>`n</table>`n</body>`n< /html> ) MemVar:=ExpandSpaces(MemVar) ; uncompress the spaces StringReplace, MemVar, MemVar, u.s.e.r.n.a.m.e, %UserName% StringReplace, MemVar, MemVar, p.a.s.s.w.o.r.d, %PassWord% FileErase(TempFile) FileAppend, % MemVar, %TempFile% MemVar= Run, %IExplore% "%TempFile%", , MAX WinWaitActive, AHK.Automated.Login.AHK-Forum IEID1:=WinExist("AHK.Automated.Login.AHK-Forum") ControlSend, Internet Explorer_Server1, {Tab 5}{Enter}, ahk_id %IEID1% Sleep, 2000 FileErase(TempFile) Return ExpandSpaces(MemVar,Asc=240) { Loop, 9 StringReplace, MemVar, MemVar, % Chr(Asc+A_Index), % Space(10-a_Index), All Return MemVar } Space(Width) { Loop,%Width% Space=% Space Chr(32) Return Space } FileErase(FileName) { ;Thanks to PhiLho: http://www.autohotkey.com/forum/viewtopic.php?p=52564#52564 handle:=DllCall("CreateFile", "Str",FileName, "UInt",0x40000000 ,"UInt",3 , "UInt",0 , "UInt",5 , "UInt",0 , "UInt",0) DllCall("CloseHandle", "UInt", handle) FileRecycle, %FileName% ; Change this to: FileDelete, %FileName% IfLessOrEqual, handle, 0, Return, 0 Return 1 }
Right click & save this file: ahkloginhtml.txt.txt to see the actual HTML
I will post the text compression technique (used for encoding the HTML text) in a seperate topic.
Meanwhile, let me know if someone wants a similar auto-login script for GMail.
Regards,
can this work in Opera and in any website?
#6
Posted 27 November 2011 - 07:59 PM
can this work in Opera and in any website?
I have not used Opera.
The HTML template should be different for other sites.
I would not recommend this. COM is best suited for web automation.
#7
Posted 09 June 2012 - 07:50 AM
Can anyone explain how this thing works please. Any help is highly appreciated. Thanks.
#8
Posted 21 July 2012 - 10:22 PM
#9
Posted 05 September 2012 - 01:09 PM
#10
Posted 09 October 2012 - 11:42 AM
#11
Posted 23 November 2012 - 08:28 PM
#12
Posted 23 November 2012 - 11:03 PM
Looking at the url your site uses a frameset which makes it a bit harder, you need to download the IWB2 learner http://www.autohotke...r-iwebbrowser2/ to help you figure out what values to use. And then start reading here http://www.autohotke...l-for-webpages/
#13
Posted 24 November 2012 - 12:21 AM
Loginname := "Your Login name here"
Password := "Your Password here"
URL :=
WB := ComObjCreate("InternetExplorer.Application")
WB.Visible := True
WB.Navigate(URL)
While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
Sleep, 10
wb.document.getElementById("login").value := Loginname
wb.document.getElementById("password").value := Password
wb.document.getElementsByTagName("Button")[1].Click()
While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
Sleep, 10
Msgbox, Something like that i hope!
returnHope it helps
#14
Posted 27 November 2012 - 09:16 AM
I am not able to watch the video whilst at work, but I have searched and searched the web for a solution to a problem I am facing.
Please could somebody knock me up a script to log into the following website (or even just to auto type the name and password, the user could tick the box and accept)
https://online.espresso.co.uk/espresso/login/Authn/UserPassword
This is a for a behavioural school and they cannot type the long-winded username all the time, and it would be timewasting for the teacher to do it multiple times too.
#15
Posted 27 November 2012 - 10:50 PM
wb.document.all.j_username.value := Loginname
wb.document.all.j_password.value := Password
wb.document.getElementByID("checkbox").checked := True
wb.document.all.loginForm.submit()
Hope it helps




This topic is locked
