#include #include #include $title = "Comcast Signal" ;Verify modem is present Ping( "192.168.100.1", 100 ) If @error Then MsgBox(0, $title, "Error locating modem at 192.168.100.1") Exit EndIf ;Verify modem by page title $ie = _IECreate( "192.168.100.1", 0, 0 ) $pagetitle = _IEPropertyGet ( $ie, "title" ) _IEQuit( $ie ) If $pagetitle <> "Modem Configuration: Status - Connection" Then MsgBox( 0, $title, "Error, Incorrect modem. Sorry" ) Exit EndIf Global $snr, $downpower, $uppower DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ; turn themes off for colors $Form1 = GUICreate($title, 200, 180, 193, 115) $snr_label = GUICtrlCreateLabel( "Loading", 8, 20, 55, 17 ) $snr_progress = GUICtrlCreateProgress(65, 20, 127, 17, 0x1) GUICtrlSetData( -1, 100 ) GUICtrlSetColor( -1, 0x00ff00 ) $downpower_label = GUICtrlCreateLabel( "Loading", 8, 59, 55, 17 ) $downpower_progress = GUICtrlCreateProgress(65, 59, 127, 17, 0x1) GUICtrlSetData( -1, 100 ) GUICtrlSetColor( -1, 0x00ff00 ) $uppower_label = GUICtrlCreateLabel( "Loading", 8, 97, 55, 17 ) $uppower_progress = GUICtrlCreateProgress(65, 97, 127, 17, 0x1) GUICtrlSetData( -1, 100 ) GUICtrlSetColor( -1, 0x00ff00 ) GUICtrlCreateLabel("Signal To Noise Ratio", 8, 3, 182, 17, $SS_RIGHT) GUICtrlCreateLabel("Downstream Power Level", 8, 41, 182, 17, $SS_RIGHT) GUICtrlCreateLabel("Upstream Power Level", 8, 79, 182, 17, $SS_RIGHT) $reset_button = GUICtrlCreateButton("Restart Modem", 8, 120, 89, 23, 0) $restore_button = GUICtrlCreateButton("Restore Defaults", 104, 120, 89, 23, 0) $modem_button = GUICtrlCreateButton("Modem Config", 8, 150, 89, 23, 0) $refresh_button = GUICtrlCreateButton("Refresh", 104, 150, 89, 23, 0) GUISetState(@SW_SHOW) update() AdlibEnable( "update", 3000 ) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $refresh_button update() Case $reset_button If MsgBox( 4, $title, "Are you sure you would like to restart your modem?" ) = 6 Then ResetReq() Case $restore_button If MsgBox( 4, $title, "Are you sure you would like to restort your modem to factory defaults?" ) = 6 Then RestoreReq() Case $modem_button Run(@ComSpec & " /c " & 'start http://192.168.100.1', "", @SW_HIDE) EndSwitch WEnd Func update() If GetStatus() = 1 Then GUICtrlSetData( $snr_label, $snr ) GUICtrlSetData( $downpower_label, $downpower ) GUICtrlSetData( $uppower_label, $uppower ) $snr = StringFormat( "%.1f", $snr ) $downpower = StringFormat( "%.1f", $downpower ) $uppower = StringFormat( "%.1f", $uppower ) If $snr < 30 Then GUICtrlSetColor( $snr_progress, 0xff0000 ) ElseIf $snr < 33 And $snr > 29 Then GUICtrlSetColor( $snr_progress, 0xffff00 ) Else GUICtrlSetColor( $snr_progress, 0x00ff00 ) EndIf $snr = Round(($snr/60)*100) If Abs($downpower) > 10 Then GUICtrlSetColor( $downpower_progress, 0xff0000 ) ElseIf Abs($downpower) < 5 And Abs($downpower) > 10 Then GUICtrlSetColor( $downpower_progress, 0xffff00 ) Else GUICtrlSetColor( $downpower_progress, 0x00ff00 ) EndIf $downpower = 100-(Abs($downpower)*9) If Abs($uppower-45) > 10 Then GUICtrlSetColor( $uppower_progress, 0xff0000 ) ElseIf Abs($uppower-45) < 5 And Abs($uppower-45) > 10 Then GUICtrlSetColor( $uppower_progress, 0xffff00 ) Else GUICtrlSetColor( $uppower_progress, 0x00ff00 ) EndIf $uppower = 100-(Abs($uppower-45)*9) Else $snr = "NO" $downpower = "MODEM" $uppower = "DETECTED" GUICtrlSetData( $snr_label, $snr ) GUICtrlSetData( $downpower_label, $downpower ) GUICtrlSetData( $uppower_label, $uppower ) EndIf GUICtrlSetData( $snr_progress, $snr ) GUICtrlSetData( $downpower_progress, $downpower ) GUICtrlSetData( $uppower_progress, $uppower ) EndFunc Func GetStatus() $ie = _IECreate( "http://192.168.100.1/RgSignal.asp", 0, 0 ) $table = _IETableGetCollection ($ie, 2) $table = _IETableWriteToArray ($table) If IsArray($table) Then Global $downpower = StringReplace( $table[1][5], "The Downstream Power Level reading is a snapshot taken at the time this page was requested. Please Reload/Refresh this Page for a new reading", "" ) Global $snr = $table[1][3] $table = _IETableGetCollection ($ie, 3) $table = _IETableWriteToArray ($table) If IsArray($table) Then Global $uppower = $table[1][3] EndIf _IEQuit($ie) Return 1 Else _IEQuit($ie) Return 0 EndIf EndFunc Func ResetReq() $soc = _HTTPConnect("192.168.100.1") If @error Then MsgBox( 0, $title, "Error opening socket" ) _HTTPPost("192.168.100.1", "/goform/RgConfig", $soc, "RestoreFactoryDefault=0&ResetReq=1") If @error Then MsgBox( 0, $title, "Error at POST request" ) _HTTPClose($soc) EndFunc Func RestoreReq() $soc = _HTTPConnect("192.168.100.1") If @error Then MsgBox( 0, $title, "Error opening socket" ) _HTTPPost("192.168.100.1", "/goform/RgConfig", $soc, "RestoreFactoryDefault=1&ResetReq=0") If @error Then MsgBox( 0, $title, "Error at POST request" ) _HTTPClose($soc) EndFunc