stimpy Posted March 30, 2006 Share Posted March 30, 2006 Hi all, Firstly many thanks to the developers of AutoIt as its a great tool (easy to use and powerful). Secondly many thansk t the many developers and contributors of libraries and scripts and for what looks like good forum support, special thanks to DaleHolm for IE.au3 and scriptkitty for javascript tidbits. Okay I'm trying to reset a motorola cable modem via its webpage interface. The problem I'm encountering is that the reset submit is tied to a javascript which pops up a windows.confirm window requiring a Ok button mouse click. The AutoIt script stops until the windows.confirm is actioned. As stated before in the support forums to use the " .click on the submit button instead of .submit on the form(normal form submission)" that Daleholm suggest this works as it is the standard tie of a javascript function to the onclick event of the submit button. Yes this work but the javascript alert causes the AutoIt script to pause. ;reset cable modem $o_all = _IETagNameAllGetCollection ($oIE) ConsoleWrite("Reset Cable Modem" & @CR) $o_all.item(113).click Now I've read the forums and the recommended method is to spawn a child process to wait for the javascript alert popup window and action on that. But I think that is messy and is there an easier way to handle this. I'll include the source of the webpage (included attachment RgConfig[1].txt) but heres the relevant code snippets : ----------------------------------------------------------------- function resetReq() { var agree=window.confirm('Are you sure you want to reset the modem?'); if (agree == true) { window.document.RgConfig.ResetReq.value = 1; } } .... <form action=/goform/RgConfig method=POST name="RgConfig"> <table border="0" cellspacing="0" width="100%" id="AutoNumber1" bordercolor="#111111" cellpadding=0> ...... <td COLSPAN=2 align="center"><input type="submit" value="Restart Cable Modem" align="center" onclick="resetReq();"> <input type="hidden" name="ResetReq" value=0> </td> ----------------------------------------------------------------- I've tried a few things but my codings to bad to get this doen so i need help. here what i was trying, basically to post directly and avoid that javascript alert popup. ----------------------------------------------------------------- $oIE = _IECreate() ;$sHTML = '<form name="RgConfig" method=post action=http://192.168.100.1/goform/RgConfig document.RgConfig.ResetReq.value="1" id="AutoNumber1"> </form>' ;$sHTML = '<form name="RgConfig" method=post action=http://192.168.100.1/goform/RgConfig document.forms[RgConfig].ResetReq.value="1" id="AutoNumber1"> </form>' _IEBodyWriteHTML($oIE, $sHTML) $oForm = _IEFormGetObjByName($oIE, "RgConfig") _IEFormSubmit($oForm) ----------------------------------------------------------------- Any help would be appreciated Chris Link to comment Share on other sites More sharing options...
DaleHohm Posted March 30, 2006 Share Posted March 30, 2006 Instead of using .click on the button, use .focus and then Send("{ENTER}") The alert still comes up but your script is free to continue. I think there is an example of the's approach in replys of the IE.au3 thread. Dale redline147 1 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 Link to comment Share on other sites More sharing options...
stimpy Posted March 30, 2006 Author Share Posted March 30, 2006 (edited) Dale thanks, still dont know how to implement that focus thing will look into it. what i was after was a shortcut to post the javascript property back to teh cgi to bypass that popup totally. The method to startup another compiled application with winwaitactive and then do somethign appears to work. //////////////// main.au3 ; Starts the compiled winwaitactive looking for alert popup Run (@comspec & " /c start waitforiepopup.exe") ;code to hit reset submit button /////////////// #include <IE.au3> ;waitforiepopup.au3 WinWaitActive("Microsoft Internet Explorer","Are you sure you want to reset the modem?") If WinActive("Microsoft Internet Explorer","Are you sure you want to reset the modem?") Then ; $text = WinGetText("Microsoft Internet Explorer", "") ; ConsoleWrite("WingetText :" &$text & @CR) ; MsgBox(0, "Text read was:", $text) Send("{ENTER}") endif Exit /////////////// EDIT: wasn't working before.. but figured it out.. Edited March 30, 2006 by stimpy Link to comment Share on other sites More sharing options...
redline147 Posted August 24, 2014 Share Posted August 24, 2014 Instead of using .click on the button, use .focus and then Send("{ENTER}") The alert still comes up but your script is free to continue. I think there is an example of the's approach in replys of the IE.au3 thread. Dale You are the master DaleHohm thank you so much. Your explinations are really clear and specific. Link to comment Share on other sites More sharing options...
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