akRJ Posted June 3, 2009 Posted June 3, 2009 Hey guys, i have a quick question. I have a script i'm writing that will go off and verify if a computer is online, offline or not on the network with the Ping command, and then change that computer's button on the gui to green, red, or yellow. I can't seem to get the loop down for changing the colors. any help would be much appreciated! here is my code. expandcollapse popupDim $i = 1 dim $response dim $label #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Maintenance Console ", 882, 701, 193, 115) $Group1 = GUICtrlCreateGroup("PCs", 192, 8, 689, 649) $btn_d1 = GUICtrlCreateButton("Desktop1", 200, 32, 89, 17, 0) $btn_d2 = GUICtrlCreateButton("Desktop2", 200, 56, 89, 17, 0) $btn_d3 = GUICtrlCreateButton("Desktop3", 200, 80, 89, 17, 0) $btn_d4 = GUICtrlCreateButton("Desktop4", 200, 104, 89, 17, 0) $btn_d5 = GUICtrlCreateButton("Desktop5", 200, 128, 89, 17, 0) $btn_d7 = GUICtrlCreateButton("Desktop7", 200, 176, 89, 17, 0) $btn_d10 = GUICtrlCreateButton("Desktop10", 200, 248, 89, 17, 0) $btn_d8 = GUICtrlCreateButton("Desktop8", 200, 200, 89, 17, 0) $btn_d6 = GUICtrlCreateButton("Desktop6", 200, 152, 89, 17, 0) $btn_d9 = GUICtrlCreateButton("Desktop9", 200, 224, 89, 17, 0) $btn_d14 = GUICtrlCreateButton("Desktop14", 200, 344, 89, 17, 0) $btn_d13 = GUICtrlCreateButton("Desktop13", 200, 320, 89, 17, 0) $btn_d35 = GUICtrlCreateButton("Desktop35", 360, 248, 89, 17, 0) $btn_d15 = GUICtrlCreateButton("Desktop15", 200, 368, 89, 17, 0) $btn_d12 = GUICtrlCreateButton("Desktop12", 200, 296, 89, 17, 0) $btn_d16 = GUICtrlCreateButton("Desktop16", 200, 392, 89, 17, 0) $btn_d11 = GUICtrlCreateButton("Desktop11", 200, 272, 89, 17, 0) $btn_d37 = GUICtrlCreateButton("Desktop37", 360, 296, 89, 17, 0) $btn_d36 = GUICtrlCreateButton("Desktop36", 360, 272, 89, 17, 0) $btn_d41 = GUICtrlCreateButton("Desktop41", 360, 392, 89, 17, 0) $btn_d38 = GUICtrlCreateButton("Desktop38", 360, 320, 89, 17, 0) $btn_d40 = GUICtrlCreateButton("Desktop40", 360, 368, 89, 17, 0) $btn_d42 = GUICtrlCreateButton("Desktop42", 360, 416, 89, 17, 0) $btn_d50 = GUICtrlCreateButton("Desktop50", 360, 608, 89, 17, 0) $btn_d39 = GUICtrlCreateButton("Desktop39", 360, 344, 89, 17, 0) $btn_d43 = GUICtrlCreateButton("Desktop43", 360, 440, 89, 17, 0) $btn_d44 = GUICtrlCreateButton("Desktop44", 360, 464, 89, 17, 0) $btn_d45 = GUICtrlCreateButton("Desktop45", 360, 488, 89, 17, 0) $btn_d46 = GUICtrlCreateButton("Desktop46", 360, 512, 89, 17, 0) $btn_d47 = GUICtrlCreateButton("Desktop47", 360, 536, 89, 17, 0) $btn_d48 = GUICtrlCreateButton("Desktop48", 360, 560, 89, 17, 0) $btn_d49 = GUICtrlCreateButton("Desktop49", 360, 584, 89, 17, 0) $btn_25 = GUICtrlCreateButton("Desktop25", 200, 608, 89, 17, 0) $btn_d24 = GUICtrlCreateButton("Desktop24", 200, 584, 89, 17, 0) $btn_d23 = GUICtrlCreateButton("Desktop23", 200, 560, 89, 17, 0) $btn_d22 = GUICtrlCreateButton("Desktop22", 200, 536, 89, 17, 0) $btn_21 = GUICtrlCreateButton("Desktop21", 200, 512, 89, 17, 0) $btn_d20 = GUICtrlCreateButton("Desktop20", 200, 488, 89, 17, 0) $btn_d19 = GUICtrlCreateButton("Desktop19", 200, 464, 89, 17, 0) $btn_d18 = GUICtrlCreateButton("Desktop18", 200, 440, 89, 17, 0) $btn_d17 = GUICtrlCreateButton("Desktop17", 200, 416, 89, 17, 0) $btn_d34 = GUICtrlCreateButton("Desktop34", 360, 224, 89, 17, 0) $btn_l1 = GUICtrlCreateButton("Laptop1", 520, 32, 89, 17, 0) $btn_d28 = GUICtrlCreateButton("Desktop28", 360, 80, 89, 17, 0) $btn_d29 = GUICtrlCreateButton("Desktop29", 360, 104, 89, 17, 0) $btn_l2 = GUICtrlCreateButton("Laptop2", 520, 56, 89, 17, 0) $btn_d30 = GUICtrlCreateButton("Desktop30", 360, 128, 89, 17, 0) $btn_d27 = GUICtrlCreateButton("Desktop27", 360, 56, 89, 17, 0) $btn_l3 = GUICtrlCreateButton("Laptop3", 520, 80, 89, 17, 0) $btn_l4 = GUICtrlCreateButton("Laptop4", 520, 104, 89, 17, 0) $btn_l5 = GUICtrlCreateButton("Laptop5", 520, 128, 89, 17, 0) $btn_d26 = GUICtrlCreateButton("Desktop26", 360, 32, 89, 17, 0) $btn_d31 = GUICtrlCreateButton("Desktop31", 360, 152, 89, 17, 0) $btn_d32 = GUICtrlCreateButton("Desktop32", 360, 176, 89, 17, 0) $btn_d33 = GUICtrlCreateButton("Desktop33", 360, 200, 89, 17, 0) $btn_l11 = GUICtrlCreateButton("Laptop11", 520, 272, 89, 17, 0) $btn_l6 = GUICtrlCreateButton("Laptop6", 520, 152, 89, 17, 0) $btn_l12 = GUICtrlCreateButton("Laptop12", 520, 296, 89, 17, 0) $btn_l9 = GUICtrlCreateButton("Laptop9", 520, 224, 89, 17, 0) $btn_l8 = GUICtrlCreateButton("Laptop8", 520, 200, 89, 17, 0) $btn_l10 = GUICtrlCreateButton("Laptop10", 520, 248, 89, 17, 0) $btn_l7 = GUICtrlCreateButton("Laptop7", 520, 176, 89, 17, 0) $btn_l13 = GUICtrlCreateButton("Laptop13", 520, 320, 89, 17, 0) $btn_l14 = GUICtrlCreateButton("Laptop14", 520, 344, 89, 17, 0) $btn_l15 = GUICtrlCreateButton("Laptop15", 520, 368, 89, 17, 0) $btn_l16 = GUICtrlCreateButton("Laptop16", 520, 392, 89, 17, 0) $btn_l17 = GUICtrlCreateButton("Laptop17", 520, 416, 89, 17, 0) $btn_l18 = GUICtrlCreateButton("Laptop18", 520, 440, 89, 17, 0) $btn_l19 = GUICtrlCreateButton("Laptop19", 520, 464, 89, 17, 0) $btn_l20 = GUICtrlCreateButton("Laptop20", 520, 488, 89, 17, 0) $btn_l21 = GUICtrlCreateButton("Laptop21", 520, 512, 89, 17, 0) $btn_l22 = GUICtrlCreateButton("Laptop22", 520, 536, 89, 17, 0) $btn_l23 = GUICtrlCreateButton("Laptop23", 520, 560, 89, 17, 0) $btn_l24 = GUICtrlCreateButton("Laptop24", 520, 584, 89, 17, 0) $btn_l25 = GUICtrlCreateButton("Laptop25", 520, 608, 89, 17, 0) $btn_wake = GUICtrlCreateButton("Wake all PCs", 0, 136, 185, 65, 0) $btn_connect = GUICtrlCreateButton("Connect to PCs", 0, 232, 185, 65, 0) $btn_deploy = GUICtrlCreateButton("Deploy Client", 0, 424, 185, 65, 0) $btn_vnc = GUICtrlCreateButton("VNC all PCs", 0, 328, 185, 65, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn_connect est_connect() EndSwitch WEnd Func est_connect() Do $label = "$btn_d"&$i $reponse = Ping("dpt"&$i) If $reponse = 1 then MsgBox(1,"",$label) GUICtrlSetBkColor($label, 0x00FF00) ElseIf @error = 1 then ElseIf @error = 4 Then EndIf $i = $i + 1 Until $i = 51 EndFunc
Valuater Posted June 3, 2009 Posted June 3, 2009 Welcome to the Forums, Sorry we missed you while you were on-line.. Hope this can help expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Dim $i = 1 Dim $response, $reponse Dim $label Global $BtnD[51], $BtnL[26], $left = 40, $top = 8, $Cnt = 0 $Form1 = GUICreate("Maintenance Console ", 882, 701, 193, 115) $Group1 = GUICtrlCreateGroup("PCs", 192, 8, 689, 649) For $ii = 1 To 3 $top = 8 $left += 160 For $x = 1 To 25 $top += 24 If $ii >= 3 Then ; create the Laptop Buttons $BtnL[$x] = GUICtrlCreateButton("Laptop " & $x, $left, $top, 89, 17, 0) Else ; Else, create the Desktop Buttons If $ii >= 2 Then $Cnt = 25 $BtnD[$x + $Cnt] = GUICtrlCreateButton("Desktop " & $x + $Cnt, $left, $top, 89, 17, 0) EndIf Next Next $btn_wake = GUICtrlCreateButton("Wake all PCs", 0, 136, 185, 65, 0) $btn_connect = GUICtrlCreateButton("Connect to PCs", 0, 232, 185, 65, 0) $btn_deploy = GUICtrlCreateButton("Deploy Client", 0, 424, 185, 65, 0) $btn_vnc = GUICtrlCreateButton("VNC all PCs", 0, 328, 185, 65, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn_connect est_connect() EndSwitch WEnd Func est_connect() $i = 1 Do $reponse = Random(1, 3, 1) ; Ping("dpt"&$i)???? i dont know this.... Sleep(500) If $reponse = 1 Then ;MsgBox(1,"",$label) GUICtrlSetBkColor($BtnD[$i], 0x00FF00) ElseIf $reponse = 2 Then GUICtrlSetBkColor($BtnD[$i], 0xFF0000) ElseIf $reponse = 3 Then GUICtrlSetBkColor($BtnD[$i], 0x00FFFF) Else MsgBox(4096, "Error", $label) EndIf $i = $i + 1 Until $i = 51 EndFunc ;==>est_connect Actually, I would consider using On-Event-Mode for this type of situation Good Luck 8)
akRJ Posted June 3, 2009 Author Posted June 3, 2009 Welcome to the Forums, Sorry we missed you while you were on-line.. Hope this can help Func est_connect() Ping("dpt"&$i)???? i dont know this.... Actually, I would consider using On-Event-Mode for this type of situation Good Luck 8) It uses the response back from the ping to determine what color the buttons for each computer will turn, online = green, off = red, bad name = yellow. Other than that your suggestion was brilliant, thanks!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now