johnhusk24 Posted January 1, 2011 Posted January 1, 2011 Hello Forum, I am a newbie just getting to grips with autoit and trying different things to learn. I have been trying to get a autoit script to work with Usermin webmail interface. I have included the html source in a comment part of my script to allow someone to help point out where I am getting trouble of input. many thanks John I tried to attach the file but had to paste it instead, sorry if this wrong #cs ; Web Page html source to login see below <!doctype html public "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <link rel='stylesheet' type='text/css' href='/unauthenticated/style.css' /> <script type='text/javascript' src='/unauthenticated/toggleview.js'></script> <script> var rowsel = new Array(); </script> <script type='text/javascript' src='/unauthenticated/sorttable.js'></script> <meta http-equiv="Content-Type" content="text/html; Charset=iso-8859-1"> <title></title> </head> <body bgcolor=#ffffff link=#0000ee vlink=#0000ee text=#000000 onload='document.forms[0].pass.value = ""; document.forms[0].user.focus()'> <table class='header' width=100%><tr> <td id='headln2l' width=15% valign=top align=left></td> <td id='headln2c' align=center width=70%><font size=+2></font></td> <td id='headln2r' width=15% valign=top align=right></td></tr></table> <p><center> <form class='ui_form' action='/session_login.cgi' method=post > <input class='ui_hidden' type=hidden name="page" value="/"> <table class='shrinkwrapper' width=40% class='loginform'> <tr><td> <table class='ui_table' width=40% class='loginform'> <thead><tr class='ui_table_head'><td><b>Login to Usermin</b></td></tr></thead> <tbody> <tr class='ui_table_body'> <td colspan=1><table width=100%> <tr class='ui_table_row'> <td valign=top colspan=2 align=center class='ui_value'>You must enter a username and password to login.</td> </tr> <tr class='ui_table_row'> <td valign=top class='ui_label'><b>Username</b></td> <td valign=top colspan=1 class='ui_value'><input class='ui_textbox' name="user" value="" size=20 ></td> </tr> <tr class='ui_table_row'> <td valign=top class='ui_label'><b>Password</b></td> <td valign=top colspan=1 class='ui_value'><input class='ui_password' type=password name="pass" value="" size=20 ></td> </tr> </tbody></table></td></tr></table> </td></tr> </table> <input class='ui_submit' type=submit value="Login"> <input type=reset value="Clear"> </form> </center> <script> if (window != window.top) { window.top.location = window.location; } </script> </div><p> <br> </body></html> ; End of Web Page html source to login. #ce ; beginning of my script #include<IE.au3> $sUsername = "usernameX" $sPassword = "passwordX" $sUrl = "http://email.website.co.uk" $oIE = _IECreate($sUrl, 0, 1, 0, 1) Sleep(2000) $oHWND = _IEPropertyGet($oIE, "hwnd") WinSetState($oHWND, "", @SW_MAXIMIZE) $oForm = _IEFormGetCollection($oIE, 0) $oUsername = _IEFormElementGetObjByName($oForm, 'ui_textbox') $oPassword = _IEFormElementGetObjByName($oForm, "ui_password") _IEFormElementSetValue($oUsername, $sUsername) _IEFormElementSetValue($oPassword, $sPassword) _IEFormSubmit($oForm)
Skitty Posted January 1, 2011 Posted January 1, 2011 (edited) What exactly is it you are trying? Automate mail? be cause if its mail you wan't to send you might want to check out this script I found. expandcollapse popup$SmtpServer = "smtp service provider" $FromName = "from who is this message?!?!" $FromAddress = "From what email is this message coming from?!?" $ToAddress = "to address" $Subject = "What is your subject?" $Body = "Info you want to send" $AttachFiles = "files you want to send" $CcAddress = "Send to mare addresses? if no leave blank" $BccAddress = "Even more addresses if you like" $Importance = "Normal" $Username = "account user name from email that used to send" $Password = "senders email password" $IPPort = 465 $ssl = 1 ;Start Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error:" & @error, "Error code:" & @error ) EndIf ; ; The UDF Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment ($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort ;Authenticated SMTP If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf ;Update settings $objEmail.Configuration.Fields.Update ; Set Email Importance Switch $s_Importance Case "High" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "High" Case "Normal" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Normal" Case "Low" $objEmail.Fields.Item ("urn:schemas:mailheader:Importance") = "Low" EndSwitch $objEmail.Fields.Update ; Sent the Message ;CREATE FUNCTION HERE TO MAKE SCRIPT LEAVE FILE BEHINDE AND PREVENT DUPLICATE EMAILS ON REBOOT $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" EndFunc ;==>_INetSmtpMailCom ; ; ; Com Error Handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF) SetError(1); something to check for when this function returns Return EndFunc ;==>MyErrFunc Edited January 1, 2011 by xJSLRx
Zedna Posted January 1, 2011 Posted January 1, 2011 _IEFormSubmit($oForm)See remarks in helpfile at _IEFormSubmit()Function _IEFormSubmitRemarksFor many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom Javascript tied to an onclick event for its Submit button. In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction(). Resources UDF ResourcesEx UDF AutoIt Forum Search
johnhusk24 Posted January 3, 2011 Author Posted January 3, 2011 What exactly is it you are trying? Automate mail? be cause if its mail you wan't to send you might want to check out this script I found. Dear xJSLRx, thank you so much for posting this script I can adapt it to do something that I had planned to do further on in learning autoit I am planning to logon to a email interface on a linux server using usermin email interface. I am planning to ready a pdf graphic file and save it to a directory which will folder watch to convert it to true pdf file. Later I want to open the file and take text strings and then copy and paste ono a web page. Thats along way ahead but this script ticks of one automation function of handling email thanks again John
johnhusk24 Posted January 3, 2011 Author Posted January 3, 2011 See remarks in helpfile at _IEFormSubmit()Function _IEFormSubmitDear Zedna,thanks you for your advice after further reading and trial and errorI have managed to get the interface workingsee attached script below where ***=username or password valuesI appreciate your time and advicethank-you#include<IE.au3>$sUsername = "****"$sPassword = "****"$sUrl = "http://email.website.co.uk"$oIE = _IECreate($sUrl, 0, 1, 0, 1)Sleep(2000)$oHWND = _IEPropertyGet($oIE, "hwnd")WinSetState($oHWND, "", @SW_MAXIMIZE)$oForm = _IEFormGetCollection($oIE, 0)$oUsername = _IEFormElementGetObjByName($oForm, 'user')$oPassword = _IEFormElementGetObjByName($oForm, "pass")_IEFormElementSetValue($oUsername, $sUsername)_IEFormElementSetValue($oPassword, $sPassword)_IEFormSubmit($oForm)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now