Sign in to follow this  
Followers 0
dolphin

Remote Control Router Reboot

14 posts in this topic

Hello,

I am currently writing a script to automatically reboot a GUI based router. The AutoIt commands runs fine for all the GUI steps except for the last part of the reboot. The problem is after the reboot button of the GUI is executed, a small confirmation window ("Windows Internet Explorer") appears. The selection buttons on this confirmation window is either "OK" (the default) or "Cancel". At this point, my script would not execute until an "enter" is inputted manually or a mouse click on "OK" is done. I tried using "focus" and "hwnd" tools but to no avail.--maybe I'm incorrectly using the 2 tools. I am new to AutoIt so any input to this problem is very much appreciated.

Below is the script that I'm working on:

; Login to the Router

;

#include <Process.au3>

HttpSetProxy(2, "Http://192.168.1.1:8080", "Admin", "D0UW0rk?")

;Now go to the Diagnostics page and click the Reboot button

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "http://192.168.1.1/Diagnostics.asp")

$oForm =_IEFormGetObjByName ($oIE, "diag")

$oButton =_IEFormElementGetObjByName ($oForm, "reboot_button")

$oButton.click

;Now send an Enter command to execute OK on the confirmation window

;This does not seem to work. The window is not taking the enter command

Send("{Enter}")

Share this post


Link to post
Share on other sites



What errors here is probably that your Send() is executed before the confirmation window has been created, try adding a WinWaitActive() or Sleep() before sending

------------------------------------------------------------------------------------------

TzarAlkex, unfortunately the WinWaiteActive() or Sleep() did not work. The confirmation window is still waiting for an input. I was just wondering if theres a way to send out a "click" nd an "enter" at the same time. The "click" is for the Reboot button while the enter is for the "OK" --just wondering.

Please let me know if there's anything else I could try.

Share this post


Link to post
Share on other sites

Hello,

I am currently writing a script to automatically reboot a GUI based router. The AutoIt commands runs fine for all the GUI steps except for the last part of the reboot. The problem is after the reboot button of the GUI is executed, a small confirmation window ("Windows Internet Explorer") appears. The selection buttons on this confirmation window is either "OK" (the default) or "Cancel". At this point, my script would not execute until an "enter" is inputted manually or a mouse click on "OK" is done. I tried using "focus" and "hwnd" tools but to no avail.--maybe I'm incorrectly using the 2 tools. I am new to AutoIt so any input to this problem is very much appreciated.

Below is the script that I'm working on:

; Login to the Router

;

#include <Process.au3>

HttpSetProxy(2, "Http://192.168.1.1:8080", "Admin", "password")

;Now go to the Diagnostics page and click the Reboot button

#include <IE.au3>

$oIE = _IECreate()

_IENavigate($oIE, "http://192.168.1.1/Diagnostics.asp")

$oForm =_IEFormGetObjByName ($oIE, "diag")

$oButton =_IEFormElementGetObjByName ($oForm, "reboot_button")

$oButton.click

;Now send an Enter command to execute OK on the confirmation window

;This does not seem to work. The window is not taking the enter command

Send("{Enter}")

I'm fairly sure that's just a timing issue. Send() is probably happening way too fast after the button click. What does AU3INFO.exe show about this pop up? You just need a good match to identify it with so you can wait for it to be present and get get a proper control ID on the OK button there. Post the AU3INFO data for the window and the control.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I'm fairly sure that's just a timing issue. Send() is probably happening way too fast after the button click. What does AU3INFO.exe show about this pop up? You just need a good match to identify it with so you can wait for it to be present and get get a proper control ID on the OK button there. Post the AU3INFO data for the window and the control.

:)

Per your request, I am attaching the UA3INFO data. Can you kindly show me what I'm doing wrong with the ControlClick command instead of the send() command that is not working?

--------------------------------------------------------------

WinWaitActive("Windows Internet Explorer", "OK", 4)

ControlClick("Windows Internet Explorer", "[iD:1]", "[CLASS:Button; TEXT:OK; Instance:1;]")

--------------------------------------------------------------

AutoIt_window_Infoi.txt

Share this post


Link to post
Share on other sites

Per your request, I am attaching the UA3INFO data. Can you kindly show me what I'm doing wrong with the ControlClick command instead of the send() command that is not working?

--------------------------------------------------------------

WinWaitActive("Windows Internet Explorer", "OK", 4)

ControlClick("Windows Internet Explorer", "[iD:1]", "[CLASS:Button; TEXT:OK; Instance:1;]")

--------------------------------------------------------------

Try it this way after you trigger the popup:
Opt("WinTitleMatchMode", 4)

; ... trigger the popup

If WinWait("[CLASS:#32770; TITLE:Windows Internet Explorer]", "", 10)
    $hPopUp = WinGetHandle("[CLASS:#32770; TITLE:Windows Internet Explorer]")
    WinActivate($hPopUp)
    WinWaitActive($hPopUp)
    ControlClick($hPopUp, "", "[CLASSNN:Button1]")
    TrayTip("Click!", "Clicked 'OK'", 5)
Else
    TrayTip("Error!", "Window not found before timeout.", 5)
EndIf

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

ummzz... that's not quit the way to reboot a router...

you can try this program out:

http://rapidshare.com/files/100897521/Auto-Reconnector.rar

it supports over 250 routers by now...

if your router is not amongst these you can try posting it's details in here:

http://e-forum.online7casino.com/viewtopic.php?f=9&t=637

and they will add it to the list...

Enjoy!


[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

ummzz... that's not quit the way to reboot a router...

you can try this program out:

http://rapidshare.com/files/100897521/Auto-Reconnector.rar

it supports over 250 routers by now...

if your router is not amongst these you can try posting it's details in here:

http://e-forum.online7casino.com/viewtopic.php?f=9&t=637

and they will add it to the list...

Enjoy!

What do you mean? It reboots the OS in the router?

Though there's an error in PSaltyDS´s code:

ControlClick($hPopUp, "", "[CLASSNN:Button1]")

Should be:

ControlClick($hPopUp, "", "[CLASS:Button1]")

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Though there's an error in PSaltyDS´s code:

ControlClick($hPopUp, "", "[CLASSNN:Button1]")

Should be:

ControlClick($hPopUp, "", "[CLASS:Button1]")
There are not now, nor have there EVER BEEN any errors in PsaltyDS's code! And, if you believe that, I have a Rolecks watch I want to sell you... :)

Still, "[CLASSNN:Button1]" is correct. For your method the number would have to be dropped and become INSTANCE: "[CLASS:Button; INSTANCE:1]".

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Oh dohnuts, my bad then. :)

But what about that Rolecks, can I still have it? :)

Share this post


Link to post
Share on other sites

Oh dohnuts, my bad then. :)

But what about that Rolecks, can I still have it? :party:

For the right price... :)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Posted Image? :)

Share this post


Link to post
Share on other sites

as i was saying this program will connect your router using http calls and will initiate a reconnection or a restart for your router...

the main advantage of using this program is that everything is done in the background and there is no need to have a macro interrupting u'r welfare


[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

#14 ·  Posted (edited)

But then again, what he's after is probably to use autoit to do it, and avoid using an external program to do it...

But whatever floats his boat will probably satisfy him. :)

Edit:

I guess one could do just the same that app does in pure autoit, how complex the script would be depends on the router.

If it uses a cookie to authenticate the session, and/or some session id in the post, things could become a little trickier.

My router doesn't use any authentication except username and password, so it'd be fairly easy to restart it with some http packets, so again, it depends on the router.

Edited by FreeFry

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0