#include Opt('WintitleMatchmode',3) ;~ get vars from ini file $server = IniRead("dswatchdog.ini", "General", "Server", "NotFound") $port = IniRead("dswatchdog.ini", "General", "HttpPort", "NotFound") $initdelay = IniRead("dswatchdog.ini", "General", "InitDelayTime", "NotFound") $watchtime = IniRead("dswatchdog.ini", "General", "WatchTime", "NotFound") $show = IniRead("dswatchdog.ini", "General", "Show", "NotFound") $guistate = IniRead("dswatchdog.ini", "General", "GuiState", "NotFound") $windowname = IniRead("dswatchdog.ini", "General", "WindowName", "NotFound") $browserpath = IniRead("dswatchdog.ini", "General", "BrowserPath", "NotFound") $regimodepath = IniRead("dswatchdog.ini", "General", "RegIEModePath", "NotFound") $regimodekey = IniRead("dswatchdog.ini", "General", "RegIEModeKey", "NotFound") $mousex = IniRead("dswatchdog.ini", "Mouse", "HideX", "NotFound") $mousey = IniRead("dswatchdog.ini", "Mouse", "HideY", "NotFound") ; Ini Values for Scheduler reboot purpose $restarttime = IniRead("dswatchdog.ini", "Restart", "Time", "NotFound") $restarttype = IniRead("dswatchdog.ini", "Restart", "ScheduleType", "NotFound") $restartweekday = IniRead("dswatchdog.ini", "Restart", "DayOfWeek", "NotFound") $offlinetittle = $windowname&" - [Working Offline]" ;~ Some Var Concatenation $url = "http://"&$server&":"&$port&"/web/"&$show&"/index.php" $openshow = $browserpath&" "&$url Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=c:\documents and settings\joão campos\desktop\aform1.kxf #include $aplicacao = GUICreate("Digital Spot Watch Dog 1.0b", 333, 619, -1, -1) GUISetIcon("dswatchdog.ico") $Groupshowinfo = GUICtrlCreateGroup("Show info", 8, 16, 313, 137) $serverlabel = GUICtrlCreateLabel("Server:", 24, 40, 38, 17) $portlabel = GUICtrlCreateLabel("Port:", 224, 40, 26, 17) $Inputserver = GUICtrlCreateInput($server, 24, 56, 169, 22) $Inputport = GUICtrlCreateInput($port, 224, 56, 73, 22) $showlabel = GUICtrlCreateLabel("Show:", 24, 96, 34, 17) $Inputshow = GUICtrlCreateInput($show, 24, 112, 169, 21) $watchtimelabel = GUICtrlCreateLabel("Watch Time (ms):", 224, 96, 87, 17) $Inputwatchtime = GUICtrlCreateInput($watchtime, 224, 112, 73, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Groupbrowserinfo = GUICtrlCreateGroup("Browser Info", 8, 168, 313, 137) $windoenamelabel = GUICtrlCreateLabel("Window Name:", 24, 192, 77, 17) $Inputwindowname = GUICtrlCreateInput($windowname, 24, 208, 281, 21) $browserpathlabel = GUICtrlCreateLabel("Browser Path:", 24, 248, 70, 17) $Inputbrowserpath = GUICtrlCreateInput($browserpath, 24, 264, 281, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Grouponlineoffline = GUICtrlCreateGroup("Online - Offline Mode", 8, 320, 313, 129) $rpathlabel = GUICtrlCreateLabel("Registry Path:", 24, 344, 70, 17) $rkeylabel = GUICtrlCreateLabel("Registry Key:", 24, 392, 66, 17) $Inputrpath = GUICtrlCreateInput($regimodepath, 24, 360, 281, 21) $Inputrkey = GUICtrlCreateInput($regimodekey, 24, 408, 281, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $quitnosavebtn = GUICtrlCreateButton("Exit without saving", 216, 560, 107, 25, 0) $applybtn = GUICtrlCreateButton("Apply ", 8, 560, 75, 25, 0) GUICtrlSetOnEvent($applybtn,"aplicar") $Groupmousecoordinates = GUICtrlCreateGroup("Hide Mouse Coordinates", 8, 464, 313, 81) $xcoordlabel = GUICtrlCreateLabel("X Coordinate", 24, 488, 65, 17) $ycoordlabel = GUICtrlCreateLabel("Y Coordinate", 184, 488, 65, 17) $Inputxcoord = GUICtrlCreateInput($mousex, 24, 504, 113, 21) $Inputyxoord = GUICtrlCreateInput($mousey, 184, 504, 113, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $File = GUICtrlCreateMenu("&File") $Exit = GUICtrlCreateMenuItem("Exit", $File) ;$Help = GUICtrlCreateMenu("&Help") ;$about = GUICtrlCreateMenuItem("About", $Help) GUICtrlSetOnEvent($Exit,"fechar") GUICtrlSetOnEvent($quitnosavebtn,"fechar") GUISetOnEvent($GUI_EVENT_CLOSE,"fechar") ;~ Read from ini file the state of gui window If $guistate = "1" Then GUISetState(@SW_SHOWMINNOACTIVE) ElseIf $guistate = "2" Then GUISetState(@SW_SHOWNORMAL) Elseif $guistate = "3" Then GUISetState(@SW_SHOWMINIMIZED) Else GUISetState(@SW_SHOWMINIMIZED) EndIf #EndRegion ### END Koda GUI section ### ;~ Delay to initiate the Script Action Sleep($initdelay) ;~ Start the show for the first time Run($openshow) ;~ Verification routine While 1 ;~ Get pc hour and week-day for reboot function $gettime = @HOUR & ":" & @MIN $getday = @WDAY ;~ TEST Server using ICMP protocol $testserver = Ping($server ,6000) Sleep(5000) ; Check the online/offline state in registry $checkiemode = RegRead($regimodepath, $regimodekey) ;~ If server ping responds OK and, in the Registry Internet state is set to offline lets change to online mode If $testserver <> 0 And $checkiemode = 1 Then ;~ Close iexplore.exe process ProcessClose("iexplore.exe") ;~ Set Internet explorer to Online Mode RegWrite ( $regimodepath, $regimodekey, "REG_DWORD", "0" ) ;~ Lets start the show... now in online mode Run($openshow) ;~ If server ping dont responds and, in the Registry Internet state is set to Online... ElseIf $testserver = 0 And $checkiemode = 0 Then ;~ Close iexplore.exe process ProcessClose("iexplore.exe") ;~ Set Internet explorer to Offline Mode RegWrite ( $regimodepath, $regimodekey, "REG_DWORD", "1" ) ;~ Lets start the show... now in online mode Run($openshow) ElseIf WinExists($windowname) = 0 And WinExists($offlinetittle) = 0 Then ;~ Close iexplore.exe process ProcessClose("iexplore.exe") ;~ This time we dont set offline or online mode, lets wait for next loop to check it out ;~ Lets start the show... now in online mode Run($openshow) ElseIf $restarttype = 1 and $gettime = $restarttime Then Shutdown(6) ; weekly ElseIf $restarttype = 2 Then if $getday = $restartweekday and $gettime = $restarttime Then Shutdown(6) Else EndIf Else EndIf ;~ Function to hide mouse cursor MouseMove($mousex, $mousey) ;~ Wait .ini ms until next loop Sleep($watchtime) WEnd ;~ Function to save and restart the script Func aplicar() IniWrite("dswatchdog.ini", "General", "Server", GUICtrlRead($Inputserver)) IniWrite("dswatchdog.ini", "General", "HttpPort", GUICtrlRead($Inputport)) IniWrite("dswatchdog.ini", "General", "WatchTime", GUICtrlRead($Inputwatchtime)) IniWrite("dswatchdog.ini", "General", "Show", GUICtrlRead($Inputshow)) IniWrite("dswatchdog.ini", "General", "WindowName", GUICtrlRead($Inputwindowname)) IniWrite("dswatchdog.ini", "General", "BrowserPath", GUICtrlRead($Inputbrowserpath)) IniWrite("dswatchdog.ini", "General", "RegIEModePath", GUICtrlRead($Inputrpath)) IniWrite("dswatchdog.ini", "General", "RegIEModeKey", GUICtrlRead($Inputrkey)) IniWrite("dswatchdog.ini", "Mouse", "HideX", GUICtrlRead($Inputxcoord)) IniWrite("dswatchdog.ini", "Mouse", "HideY", GUICtrlRead($Inputyxoord)) run(@AutoItExe) Exit EndFunc ;~ Function to Close the script Func fechar() MsgBox(0,"Closing DS Watch Dog!", "You are closing DS Watch Dog. If you want to run it again, please do it mannualy.",30) Exit EndFunc