Sign in to follow this  
Followers 0
Hyflex

Following Function doesn't return msg box..

4 posts in this topic

The following Function doesn't return with the Message Box, I want it to ping the router's IP and when it returns positive for the message to pop up.. (might change to tooltip or traytip also)

Func RebootHard()
Dim $oXML = ObjCreate('Microsoft.XMLHTTP')
Dim $aMatch

    $oXML.Open('GET', 'http://192.168.1.1/Reboot.asp', True, 'admin', 'admin')

    $oXML.Open('GET', 'http://192.168.1.1/apply.cgi?submit_button=Reboot_validate&action=Rebootvalidate&submit_type=HRebootvalidate&reboot_username=admin&reboot_password=admin&sub_button=Submit', True, 'admin', 'admin')
    
    $oXML.Send
    $IP = "192.168.1.1"
    Ping($IP, 99999999999999999999999999999)
    MsgBox(3, 'Hard Reboot Complete', 'Hard Reboot Complete (Please Wait for the Router to connect)', 5000)
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

you may loop:

$ip = "192.168.1.1"
Global $sec = 60

If _myping ($ip) Then
    MsgBox (0,"Success", "IP " & $ip & " pingable!")
Else
    MsgBox (0,"Error", "IP " & $ip & " not pingable!")
EndIf

;Ping maximum $sec seconds (here: 60, see above) given IP Address
Func _myping ($iptoping)
    ToolTip ("Pinging " & $iptoping, 0,0)
    $count = 0
    While $count < $sec
        If Ping ($iptoping, 500) > 0 Then 
            ToolTip ("")
            Return 1
        EndIf
        Sleep (500)
        $count += 1
    Wend
    ToolTip ("")
    Return 0
EndFunc

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

So the following script makes sense?

How do i use "Tidy", it used to be easy but now it is not..

HotKeySet("{Pause}", "Pause")

Global $bPaused = False
Global $versionnumber = "v1.0.0.0 (30-12-2009)"
Global $mainguititel = "Router Reboot and Reconnect, " & $versionnumber
Global $sec = 60

$ip = "192.168.1.1"
$site = "bbc.co.uk"

TraySetClick(8)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)

$Tray_ReconnectJDownloader = TrayCreateItem("Reconnect JD")
TrayItemSetOnEvent(-1, "ReconnectJD")
$Tray_ReconnectHTTP = TrayCreateItem("Reconnect HTTP")
TrayItemSetOnEvent(-1, "ReconnectHTTP")
$Tray_RebootHard = TrayCreateItem("Reboot Hard")
TrayItemSetOnEvent(-1, "RebootHard")
$Tray_RebootSoft = TrayCreateItem("Reboot Soft")
TrayItemSetOnEvent(-1, "RebootSoft")
$Tray_Exit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "Terminate")

While 1
    Sleep(100)
WEnd

Func ReconnectHTTP()
Dim $oXML = ObjCreate('Microsoft.XMLHTTP')
Dim $aMatch
    $oXML.Open('GET', 'http://192.168.1.1/Status_Router.asp', True, 'admin', 'admin')
    $oXML.Open('GET', 'http://192.168.1.1/apply.cgi?submit_button=Status_Router&submit_type=disconnect&change_action=gozila_cgi&wan_proto=dhcp', True, 'admin', 'admin')
    $oXML.Send
    If _myping ($ip) Then
    TrayTip("Router is Active", "Reconnecting Router via HTTP Method" & @CRLF & "Processing Information... Please Wait!", 30, "")
    Else
    TrayTip("Router is In-Active", "Reconnecting Router via HTTP Method has FAILED - Please reboot manually", 60, "")
    EndIf
    $oXML.Open('GET', 'http://192.168.1.1/apply.cgi?submit_button=Status_Router&submit_type=connect&change_action=gozila_cgi&wan_proto=dhcp', True, 'admin', 'admin')
    $oXML.Send  
    If _connected ($site) Then
    TrayTip("Router is Connected", "Successfully Connected", 30, "")
    Else
    TrayTip("Router is Not-Connected", "Unsuccessful Connection - Please Reconnect Manually", 60, "")
    EndIf
EndFunc

Func ReconnectJD()
Dim $oXML = ObjCreate('Microsoft.XMLHTTP')
Dim $aMatch
    $oXML.Open('GET', 'http://192.168.1.1/Status_Router.asp', True, 'admin', 'admin')
    $oXML.Open('GET', 'http://192.168.1.1/apply.cgi?submit_button=Status_Router&submit_type=disconnect&change_action=gozila_cgi&wan_proto=pppoe', True, 'admin', 'admin')
    $oXML.Send
    If _myping ($ip) Then
    TrayTip("Router is Active", "Reconnecting Router via JD Method" & @CRLF & "Processing Information... Please Wait!", 30, "")
    Else
    TrayTip("Router is In-Active", "Reconnecting Router via JD Method has FAILED - Please reboot manually", 60, "")
    EndIf
    $oXML.Open('GET', 'http://192.168.1.1/apply.cgi?submit_button=Status_Router&submit_type=connect&change_action=gozila_cgi&wan_proto=pppoe', True, 'admin', 'admin')
    $oXML.Send  
    If _connected ($site) Then
    TrayTip("Router is Connected", "Successfully Connected", 30, "")
    Else
    TrayTip("Router is Not-Connected", "Unsuccessful Connection - Please Reconnect Manually", 60, "")
    EndIf
EndFunc

Func RebootHard()
Dim $oXML = ObjCreate('Microsoft.XMLHTTP')
Dim $aMatch
    $oXML.Open('GET', 'http://192.168.1.1/Reboot.asp', True, 'admin', 'admin')
    $oXML.Open('GET', 'http://192.168.1.1/apply.cgi?submit_button=Reboot_validate&action=Rebootvalidate&submit_type=HRebootvalidate&reboot_username=admin&reboot_password=admin&sub_button=Submit', True, 'admin', 'admin')
    $oXML.Send
    If _myping ($ip) Then
    TrayTip("Router is Active", "Hardware Reboot In Progress" & @CRLF & "Processing Information... Please Wait!", 30, "")
    Else
    TrayTip("Router is In-Active", "Hardware Software Reboot has FAILED - Please Reboot Manually", 60, "")
    EndIf
    If _connected ($site) Then
    TrayTip("Router is Connected", "Successfully Connected", 30, "")
    Else
    TrayTip("Router is Not-Connected", "Unsuccessful Connection - Please Reconnect Manually", 60, "")
    EndIf
EndFunc

Func RebootSoft()
Dim $oXML = ObjCreate('Microsoft.XMLHTTP')
Dim $aMatch
    $oXML.Open('GET', 'http://192.168.1.1/Reboot.asp', True, 'admin', 'admin')
    $oXML.Open('GET', 'http://192.168.1.1/apply.cgi?submit_button=Reboot_validate&action=Rebootvalidate&submit_type=SRebootvalidate&reboot_username=admin&reboot_password=admin&sub_button=Submit', True, 'admin', 'admin')
    $oXML.Send
    If _myping ($ip) Then
    TrayTip("Router is Active", "Software Reboot In Progress" & @CRLF & "Processing Information... Please Wait!", 30, "")
    Else
    TrayTip("Router is In-Active", "Software Reboot has FAILED - Please Reboot Manually", 60, "")
    EndIf
    If _connected ($site) Then
    TrayTip("Router is Connected", "Successfully Connected", 30, "")
    Else
    TrayTip("Router is Not-Connected", "Unsuccessful Connection - Please Reconnect Manually", 60, "")
    EndIf
EndFunc

Func _myping ($iptoping)
    TrayTip("Pinging Router", "Pinging" & $iptoping, 10, "")
    $count = 0
    While $count < $sec
        If Ping ($iptoping, 500) > 0 Then 
            ToolTip ("")
            Return 1
        EndIf
        Sleep (500)
        $count += 1
    Wend
    ToolTip ("")
    Return 0
EndFunc

Func _connected ($sitetoping)
    TrayTip("Checking Online Status", "Pinging" & $sitetoping, 10, "")
    $count = 0
    While $count < $sec
        If Ping ($sitetoping, 500) > 0 Then 
            ToolTip ("")
            Return 1
        EndIf
        Sleep (500)
        $count += 1
    Wend
    ToolTip ("")
    Return 0
EndFunc

Func Pause()
    $bPaused = Not $bPaused
    If $bPaused Then
        While $bPaused
            Sleep(50)
        WEnd
    EndIf
EndFunc

Func Terminate()
    Exit 0
EndFunc
Edited by XxXGoD

Share this post


Link to post
Share on other sites

How do i use "Tidy", it used to be easy but now it is not..

Ctrl+T in SciTE assuming you have installed the separate SciTE4AutoIt3 installer.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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