ilkertezcan 0 Posted October 27, 2007 I want restart of my INCA ADSL router modem in background and silent(one-clicked exe). I looked from console of modem and I selected/prepared this HTML page:http://safirkare.googlepages.com/INCA_Modem_Restart.htmThis HTML page my router modem to restarting (disconnection) after modem login. I don't want always this html page run. I want silent runing an EXE file(one time).I encountered AutoIt today. Very good program. How be this HTML to AU3 codes? I don't know. Are you may help? I'll be glad if you inform me about this.HTML+Javascript code is simple:FORM ACTION=http://192.168.1.1/cgi-bin/webcmPOST DATA1) username: "login:command/username" + Submit2) password: "login:command/password" + Submit3) restart: "logic:command/reboot" + SubmitNote: I'm so sorry bad my english. Share this post Link to post Share on other sites
weaponx 16 Posted October 27, 2007 What is the exact model name / number of this device? If it has telnet access this would be much easier to accomplish. Share this post Link to post Share on other sites
Nahuel 1 Posted October 27, 2007 Why not just use IE.au3? Should be easy too. Share this post Link to post Share on other sites
ilkertezcan 0 Posted October 27, 2007 (edited) My ADSL Modem model: INCA IM-204 ADSL 2/2+ ROUTER (Made for Turkey)Console (192.168.1.1) similar to Motorola 2442 router. Similar page: http://www.angelfire.com/planet/mta2442/home.htmlI can't login with telnet(Port 23 is opened). I dont understand to Telnet.Router automatic to login: http://safirkare.googlepages.com/1_Login.htmRouter automatic to restart: http://safirkare.googlepages.com/2_Restart.htmI combined to both page: http://safirkare.googlepages.com/INCA_Modem_Restart.htmI tried IE Builder(IE3.au). This code don't working:CODE#include <IE.au3>$oIE = _IECreate()_IENavigate($oIE, "http://192.168.1.1")$o_form = _IEFormGetObjByName($oIE, "f1")$o_login = _IEFormElementGetObjByName($o_form, "login:command/username")$o_password = _IEFormElementGetObjByName($o_form, "login:command/password")$o_restart = _IEFormElementGetObjByName($o_form, "logic:command/reboot")_IEFormElementSetValue($o_login, "admin")_IEFormElementSetValue($o_password, "admin")_IEFormElementSetValue($o_restart, "")_IEFormSubmit($o_form)ExitI don't want to open from IE. I want to silent mode; no alert, no IE, no button, direct to restart. I think this possible. But I don't know AutoIt script.Of course, I need you help. Edited October 27, 2007 by ilkertezcan Share this post Link to post Share on other sites
Armand 2 Posted October 27, 2007 any info anyone can contribute on that subject will be helpful for me too... as i've been using a macro maker i've made to automate the reconnection of my router and as my other many users of that program - it's problematic that method! [u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?! Share this post Link to post Share on other sites
DaleHohm 65 Posted October 27, 2007 Once you get it working in IE.au3 you can make it invisible. I'm guessing that there are items on the page being generated by javascript and you are using view source to get name... Please use DebugBar (see my sig) to examine the page - your approach looks good. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curlMSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object modelAutomate input type=file (Related)Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better?IE.au3 issues with Vista - WorkaroundsSciTe 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 Share this post Link to post Share on other sites
ilkertezcan 0 Posted October 27, 2007 Thanks to Armand & DaleHohm. I tried Debugbar and Macro Recording Tools. Both useful utiliy. Thanks.I tried with wget, too. I succeeded reset my router. wget command-line:CODEwget -o nul http://192.168.1.1/cgi-bin/webcm --post-data="login:command/username=&login:command/password="wget -o nul http://192.168.1.1/cgi-bin/webcm --post-data="logic:command/reboot"As you can see, all element is post data string. another element no need. Share this post Link to post Share on other sites
flyingboz 2 Posted October 27, 2007 Kind of a punt, but you could use the RunWait() command to call your wget command line, and compile the resulting utility if you persist in having problems getting your IE calls right. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Share this post Link to post Share on other sites
ilkertezcan 0 Posted October 28, 2007 I don't want load to WGet. I think, reset post data very simple with "HTTP.au3". I written this code but don't working. Where is error? CODE #include <HTTP.au3> _HTTPConnect("192.168.1.1/cgi-bin/webcm") _HTTPPost("192.168.1.1/cgi-bin/webcm", "login:command/username=&login:command/password=&logic:command/reboot") Share this post Link to post Share on other sites
flyingboz 2 Posted October 28, 2007 I don't want load to WGet. I think, reset post data very simple with "HTTP.au3". I written this code but don't working. Where is error?CODE#include <HTTP.au3>_HTTPConnect("192.168.1.1/cgi-bin/webcm")_HTTPPost("192.168.1.1/cgi-bin/webcm", "login:command/username=&login:command/password=&logic:command/reboot")HIIK. What errors if any are thrown?why don't you just open your router for external admin access, post the ip , and let the forum debug. <lol>When you can't go online b/c the router keeps reboting on you , check back. I'll have found the bug. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Share this post Link to post Share on other sites
ilkertezcan 0 Posted October 28, 2007 (edited) Thank you flyingboyz. I succeded reset to router with AutoIt3! This code working(from Hasher). Thanks to Hasher!CODE$sUrl = "http://192.168.1.1/cgi-bin/webcm"$PostData = "login:command/username=&login:command/password="$oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP")$oHttpRequest.Open ("POST", $sUrl,True)$oHttpRequest.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded") $oHttpRequest.setRequestHeader ("Connection", "Keep-Alive")$oHttpRequest.Send ($PostData)sleep(1000)$sUrl = "http://192.168.1.1/cgi-bin/webcm"$PostData = "logic:command/reboot"$oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP")$oHttpRequest.Open ("POST", $sUrl,True)$oHttpRequest.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded") $oHttpRequest.setRequestHeader ("Connection", "Keep-Alive")$oHttpRequest.Send ($PostData)Waiting, waiting, waiting after Router reset. Show this alert box:CODE"Line -1:Error: The requested action with this object has failed."I think, Script waiting for response. No need response. Because reset made, disconnected. AutoIt3 making debug? I want exit/terminate immediately from script/program. Which command close to debug/alert/error box? Edited October 28, 2007 by ilkertezcan Share this post Link to post Share on other sites
flyingboz 2 Posted October 28, 2007 if you want to trap the error, install a com error handler -- refer to the docs. this, properly done, will tell you which call is generating the error (obviously it's a line of code after your reboot has ocurred), and you can start taking a look at the pertinent code. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Share this post Link to post Share on other sites
BrettF 28 Posted October 28, 2007 (edited) Look at using this: $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler ; Performing a deliberate failure here (object does not exist) $oIE = ObjCreate("InternetExplorer.Application") $oIE.visible = 1 $oIE.bogus if @error then Msgbox(0,"","the previous line got an error.") Exit ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription ) SetError(1); something to check for when this function returns Endfunc EDIT: That is an example of usage. There is a better one somewhere... Add this into you script: $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"COM Error Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1); to check for after this function returns Endfunc Edited October 28, 2007 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Share this post Link to post Share on other sites
ilkertezcan 0 Posted October 28, 2007 (edited) I added to script and this reporting:Error CodeI succeeded close to error MsBox. No error box. $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") (...) Func MyErrFunc() if @error then Exit EndfuncWorking proper but still waiting for exit. Edited October 29, 2007 by ilkertezcan Share this post Link to post Share on other sites
ilkertezcan 0 Posted October 29, 2007 I found to "HttpRequest.setTimeouts" command of "MSXML2.ServerXMLHTTP". I reduced to timeout numbers. Thus worked.This project successfully completed. Thank you all...Completed code:$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $ResolveTimeout = 1 $ConnectTimeout = 1 $SendTimeout = 1 $ReceiveTimeout = 1 $sUrl = "http://192.168.1.1/cgi-bin/webcm" $PostData = "login:command/username=&login:command/password=" $oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP") $oHttpRequest.Open ("POST", $sUrl, False) $oHttpRequest.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded") $oHttpRequest.setTimeouts (1, 1, 1, 1) $oHttpRequest.Send ($PostData) $sUrl = "http://192.168.1.1/cgi-bin/webcm" $PostData = "logic:command/reboot" $oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP") $oHttpRequest.Open ("POST", $sUrl, False) $oHttpRequest.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded") $oHttpRequest.setTimeouts (1, 1, 1, 1) $oHttpRequest.Send ($PostData) Func MyErrFunc() if @error then Exit Endfunc Share this post Link to post Share on other sites