pkoppelaar Posted January 30, 2007 Posted January 30, 2007 Script. #include <IE.au3> _IEErrorHandlerRegister() $ie = _IECreate("http://0.0.0.0/en/l4/cs_system_ini.html") ; Login as admin WinWaitActive("Connect to 0.0.0.0") Send("admin{TAB}admin{ENTER}") $form = _IEGetObjByName ($ie, "form") $inputbox = _IEFormElementGetObjByName($form, "SetFileName") _IEFormElementSetValue($inputbox, "C:\file.cfg") _IEFormSubmit($form) _IELoadWait($ie) _IEQuit($ie) ; Finished! Without the ErrorHandlerRegister, this is what the log says: C:\Program Files\AutoIt3\Include\IE.au3 (2399) : ==> The requested action with this object has failed.: Return $o_object.document Return $o_object.document^ ERROR With the handler it says this: expandcollapse popup--> COM Error Encountered in script.au3 ----> $IEComErrorScriptline = 2399 ----> $IEComErrorNumberHex = 800706BA ----> $IEComErrorNumber = -2147023174 ----> $IEComErrorWinDescription = The RPC server is unavailable. ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = 997 --> COM Error Encountered in script.au3 ----> $IEComErrorScriptline = 1051 ----> $IEComErrorNumberHex = 000000A9 ----> $IEComErrorNumber = 169 ----> $IEComErrorWinDescription = Variable must be of type 'Object'. ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = 0 --> COM Error Encountered in script.au3 ----> $IEComErrorScriptline = 1051 ----> $IEComErrorNumberHex = 000000A9 ----> $IEComErrorNumber = 169 ----> $IEComErrorWinDescription = Variable must be of type 'Object'. ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = 0 --> IE.au3 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch --> IE.au3 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType --> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType --> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType --> IE.au3 Error from function _IELoadWait, $_IEStatus_InvalidObjectType --> IE.au3 Error from function _IEAction, $_IEStatus_InvalidObjectType >Exit code: 0 Time: 88.545 Part of HTML page ... <FORM method="post" action="/command/all-configuration.cgi" name="form" onsubmit="return newpage(0)" enctype="multipart/form-data"> <TR> <TD ALIGN=left> <span id="restore"> Restore setting </span> </TD> <TD><input type=file name=SetFileName> <input type=submit value=" OK "></TD> </TR> </FORM> ...
DaleHohm Posted January 30, 2007 Posted January 30, 2007 (edited) There are lots of sources of trouble in the scenario you have here. First, having anything with a name of "form" or any other TagName is likely to throw the DOM for a loop -- this has nothing to do with AutoIt or IE.au3, it is just a very bad idea. You'll need to use _IEFormGetCollection instead of _IEFormGetObjByName and get the form reference by index instead of by name. Second, the form element you are trying to set the value for is type=file -- security restrictions prevent you from doing this in script. This is documented with suggested workaround in the helpfile. See the remarks in _IEFormElementSetValue. Dale Edit: typo Edited January 30, 2007 by DaleHohm Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
pkoppelaar Posted January 31, 2007 Author Posted January 31, 2007 (edited) #include <IE.au3> ;_IEErrorHandlerRegister() AutoItSetOption("WinTitleMatchMode", 1) $ie = _IECreate("http://0.0.0.0/en/l4/cs_system_ini.html") WinWait("Connect to 0.0.0.0") Send("admin{TAB}admin{ENTER}") $form = _IEFormGetCollection ($ie, 0) $inputbox = _IEFormElementGetCollection ($form, 0) _IEAction($inputbox, "focus") Send("C:\file.cfg") ;_IEFormSubmit($form) ;_IELoadWait($ie) ;_IEQuit($ie) ; Finished! This doesn't work... This is the page's full HTML. expandcollapse popup<HTML> <HEAD> <TITLE>System Initialzation</TITLE> <link rel=stylesheet href="style.css" type="text/css"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <script LANGUAGE="Javascript1.2" SRC="/command/inquiry.cgi?inqjs=system" TYPE="text/javascript"></SCRIPT> <script LANGUAGE="Javascript1.2" SRC="/command/etc.cgi" TYPE="text/javascript"></SCRIPT> <style TYPE="text/css"> <!-- BODY, TH, TD { font-size: 16px; } A { text-decoration: none; } --> </style> <script type="text/Javascript"><!-- function newpage(i){ switch(i){ case 0: if(confirm('The SNC-RZ25 will be rebooted. Are you sure?')) return true; else return false; break; case 1: if(confirm('Setup data will be initialized. Are you sure?')) return true; else return false; break; case 2: if(confirm('Upgrade firmware? Are you sure?')) { return true; }else{ return false; } break; } } //--> </script> </HEAD> <BODY TEXT=#FFFFFF LINK=#FFFFFF ALINK=#FFFFFF VLINK=#FFFFFF TOPMARGIN=0 LEFTMARGIN=0> <TABLE class="bgOn" BORDER=0 CELLPADDING=0 CELLSPACING=0> <TR> <TD><IMG SRC="../../image/blue/rc1.gif" WIDTH=7 HEIGHT=7></TD> <TD><IMG SRC="../../image/blue/null.gif" WIDTH=600 HEIGHT=7></TD> <TD><IMG SRC="../../image/blue/rc2.gif" WIDTH=7 HEIGHT=7></TD> </TR> <TR class="bk"> <TD><IMG SRC="../../image/blue/null.gif" WIDTH=7 HEIGHT=300></TD> <TD ALIGN=left VALIGN=top><TABLE BORDER=0 CELLPADDING=7 CELLSPACING=0> <FORM method="post" name=reboot_form action="/command/main.cgi" onsubmit="return newpage(0)"> <TR> <TD ALIGN=left> <span id="reboot"> Reboot </span> </TD> <TD><input type=hidden name=System value=reboot><input type=submit value=Reboot></TD> </TR> </FORM> <FORM method="post" name=factory_form action="/command/main.cgi" onsubmit="return newpage(1)"> <TR> <TD ALIGN=left> <span id="reset"> Factory default </span> </TD> <TD><input type=hidden name=System value=initialize><input type=submit value=Factory default></TD> </TR> </FORM> <FORM method="get" action="/system/snc-rz25.cfg"> <TR> <TD ALIGN=left> <span id="backup"> Backup setting data </span> </TD> <TD><input type=submit value=Save></TD> </TR> </FORM> <FORM method="post" action="/command/all-configuration.cgi" name="form" onsubmit="return newpage(0)" enctype="multipart/form-data"> <TR> <TD ALIGN=left> <span id="restore"> Restore setting </span> </TD> <TD><input type=file name=SetFileName> <input type=submit value=" OK "></TD> </TR> </FORM> <FORM method="post" action="/command/main.cgi" name="dele_form1"> <TR> <TD ALIGN=left> <span> Delete user setting URL </span> </TD> <TD><input type="hidden" name="Delete" value="homepage"> <input type=submit value=" Delete "></TD> </TR> </FORM> <FORM method="post" action="/command/main.cgi" name="dele_form2"> <TR> <TD ALIGN=left> <span> Delete panorama image </span> </TD> <TD><input type="hidden" name="Delete" value="panorama"> <input type=submit value=" Delete "></TD> </TR> </FORM> <TR> <TD ALIGN=right> </TD> <TD> </TD> </TR> <TR> <TD ALIGN=right> </TD> <TD> </TD> </TR> <TR> <TD ALIGN=right> </TD> <TD> </TD> </TR> <TR> <FORM method="post" name="form" action="/command/versionup.cgi" enctype="multipart/form-data" onsubmit="return newpage(2)"> <TD ALIGN=left> <span id="vup"> Firmware upgrade </span> </TD> <TD><input type="file" name="setting_file"> <input type="submit" value=" OK "></TD> </FORM> </TR> <TR> <TD> </TD> <TD> <span id="sys_ini_msg"> Do not select a file other than an upgrade file for SNC-RZ25. </span> </TD> </TR> </TABLE> </TD> <TD><IMG SRC="../../image/blue/null.gif" WIDTH=7 HEIGHT=300></TD> </TR> <TR> <TD><IMG SRC="../../image/blue/rc3.gif" WIDTH=7 HEIGHT=7></TD> <TD><IMG SRC="../../image/blue/null.gif" WIDTH=600 HEIGHT=7></TD> <TD><IMG SRC="../../image/blue/rc4.gif" WIDTH=7 HEIGHT=7></TD> </TR> </TABLE> </BODY> </HTML> And log: C:\Program Files\AutoIt3\Include\IE.au3 (2399) : ==> The requested action with this object has failed.: Return $o_object.document Return $o_object.document^ ERROR >Exit code: 0 Time: 59.613 Edited January 31, 2007 by pkoppelaar
DaleHohm Posted January 31, 2007 Posted January 31, 2007 I'm guessing that entering admin admin with the Send command is causing a change to the page (refresh, new location, something). Likely assing an _IELoadWait($ie) after the Send command will get you going. Also, it looks like the form index you want is 3 rather than 0. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
pkoppelaar Posted February 1, 2007 Author Posted February 1, 2007 (edited) Thanks for your help man! Another problem is that every once in a while the script hangs when the Connect to ... popup is visible and credentials need to be entered. I think it has something to do with the WinWait command. I couldn't test your remarks yet 'cause of that just now. Edit: Hmm, when I open up the SciTE help the script suddenly continues!... Any idea what might cause this? When running the script with _IELoadWait($ie) I get the following error: --> IE.au3 Error from function _IELoadWait, $_IEStatus_InvalidObjectType Edited February 1, 2007 by pkoppelaar
Shevilie Posted February 1, 2007 Posted February 1, 2007 He mean #include <IE.au3> _IEErrorHandlerRegister() $ie = _IECreate("http://0.0.0.0/en/l4/cs_system_ini.html") ; Login as admin WinWaitActive("Connect to 0.0.0.0") Send("admin{TAB}admin{ENTER}") _IELoadWait[$ie] $form = _IEGetObjByName ($ie, "form") $inputbox = _IEFormElementGetObjByName($form, "SetFileName") _IEFormElementSetValue($inputbox, "C:\file.cfg") _IEFormSubmit($form) _IELoadWait($ie) _IEQuit($ie) ; Finished! Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
DaleHohm Posted February 1, 2007 Posted February 1, 2007 Thanks for your help man! Another problem is that every once in a while the script hangs when the Connect to ... popup is visible and credentials need to be entered. I think it has something to do with the WinWait command. I couldn't test your remarks yet 'cause of that just now. Edit: Hmm, when I open up the SciTE help the script suddenly continues!... Any idea what might cause this? When running the script with _IELoadWait($ie) I get the following error: --> IE.au3 Error from function _IELoadWait, $_IEStatus_InvalidObjectTypeShevilie's reply should help you with the console error. Regarding the stall, this has been discussed several times in the forum. It has to do with the interaction of the embedded script in the browser - for example, See discussion here Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
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