gcue Posted February 19, 2008 Share Posted February 19, 2008 hello all. i have a script that does some pinging on devices specified by the user. id like to add a section in the gui that shows the status of what its doing.. im sure its possible just dunno how to do it - any help is appreciated - thanks! here's what the gui looks like expandcollapse popupparent = GUICreate("Device Pinger v0.1", 275, 200) $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Ping Devices",$filemenu) GUICtrlSetOnEvent(-1,"PingDevices") $fileitem = GUICtrlCreateMenuitem ("Edit Device List",$filemenu) GUICtrlSetOnEvent(-1,"EditCSV") $fileitem = GUICtrlCreateMenuitem ("Export Status to CSV",$filemenu) GUICtrlSetOnEvent(-1,"ExportCSV") $helpmenu = GUICtrlCreateMenu ("&Help") $helpitem = GUICtrlCreateMenuitem ("About",$helpmenu) GUICtrlSetOnEvent(-1,"About") GUISetOnEvent($GUI_EVENT_CLOSE, "XButton") ;$background = GUICtrlCreatePic ("pong.jpg", 110, 0, 100, 46) GUISetState(@SW_SHOW) While 1 Sleep(1000) WEndoÝ÷ Ù©ÝêÞ³Z¶Êîx§)íæÚrH+¢éÝjëh×6Func PingDevices() If FileExists(@TempDir & "\status.csv") Then FileDelete (@TempDir & "\status.csv") FileWrite($statusfile, "Location, Device, Status") EndIf Local $location, $L, $device, $d $location = IniReadSectionNames(@UserName & "\devices.ini") If IsArray($location) Then For $L = 1 To $location[0] $device = IniReadSection(@UserName & "\devices.ini", $location[$L]) If IsArray($device) Then For $d = 1 To $device[0][0] Ping($device[$d][1]) If @error Then $status="OFFLINE" EndIf If Not @error Then $status="ONLINE" EndIf FileWrite($statusfile, '' &@CRLF & _ $location[$L] & "," & $device[$d][0] & "," & $status) Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$L] & @CRLF & "Section Number was: " & $L) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIf EndFunc Link to comment Share on other sites More sharing options...
Valuater Posted February 19, 2008 Share Posted February 19, 2008 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #Include <GuiStatusBar.au3> Dim $statusfile $parent = GUICreate("Device Pinger v0.1", 275, 200) $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Ping Devices",$filemenu) GUICtrlSetOnEvent(-1,"PingDevices") $fileitem = GUICtrlCreateMenuitem ("Edit Device List",$filemenu) ;GUICtrlSetOnEvent(-1,"EditCSV") $fileitem = GUICtrlCreateMenuitem ("Export Status to CSV",$filemenu) ;GUICtrlSetOnEvent(-1,"ExportCSV") $helpmenu = GUICtrlCreateMenu ("&Help") $helpitem = GUICtrlCreateMenuitem ("About",$helpmenu) ;GUICtrlSetOnEvent(-1,"About") $hStatus = _GUICtrlStatusBar_Create ($parent, 100, "This is a status bar") ;GUISetOnEvent($GUI_EVENT_CLOSE, "XButton") ;$background = GUICtrlCreatePic ("pong.jpg", 110, 0, 100, 46) GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd see status bar in help for further info 8) Link to comment Share on other sites More sharing options...
gcue Posted February 19, 2008 Author Share Posted February 19, 2008 ahh actually what i meant was status like this: ---------status-------------- pinging device 1 ... Online pinging device 2 ... offline and if it gets too long where itd automatically create scroll within the window. Link to comment Share on other sites More sharing options...
Gigglestick Posted February 19, 2008 Share Posted February 19, 2008 Just add an edit control maybe. My UDFs: ExitCodes Link to comment Share on other sites More sharing options...
gcue Posted February 19, 2008 Author Share Posted February 19, 2008 edit control?Just add an edit control maybe. Link to comment Share on other sites More sharing options...
Zedna Posted February 19, 2008 Share Posted February 19, 2008 Use ListView with two columns: "Device name", "Status" Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Ealric Posted February 19, 2008 Share Posted February 19, 2008 (edited) Added a View > Status menu so that you can check or uncheck whether or not you want the status label to appear Added a case code for the View > status menu Created a status label for you (you need to update the location in your GUI (usually at the bottom is a good place as it has a sunken appearance) Added an update to your ping function Check all the NEW CODE remarks Updated this to counter the fact that no global variables were defined and in this case they shouldn't have to be. So, initial label is set with a short statement. expandcollapse popup$parent = GUICreate("Device Pinger v0.1", 275, 200) $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Ping Devices", $filemenu) GUICtrlSetOnEvent(-1, "PingDevices") $fileitem = GUICtrlCreateMenuItem("Edit Device List", $filemenu) GUICtrlSetOnEvent(-1, "EditCSV") $fileitem = GUICtrlCreateMenuItem("Export Status to CSV", $filemenu) GUICtrlSetOnEvent(-1, "ExportCSV") ; setup a view menu with status checked so users can check/uncheck status ; NEW CODE $viewmenu = GUICtrlCreateMenu("View", -1, 2) $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState($viewstatusitem, $GUI_CHECKED) $helpmenu = GUICtrlCreateMenu("&Help") $helpitem = GUICtrlCreateMenuItem("About", $helpmenu) GUICtrlSetOnEvent(-1, "About") GUISetOnEvent($GUI_EVENT_CLOSE, "XButton") ; create your status label and place it where you want in your GUI ; NEW CODE $statuslabel = GUICtrlCreateLabel("No Devices Pinged Yet" , 119, 590, 129, 17, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState(@SW_SHOW) While 1 Sleep(1000) ; NEW CODE - assuming you are running ping somewhere in the code and updating the status label under view if you want to show/hide it. PingDevices() Select Case $msg = $viewstatusitem If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf EndSelect WEnd Func PingDevices() If FileExists(@TempDir & "\status.csv") Then FileDelete(@TempDir & "\status.csv") FileWrite($statusfile, "Location, Device, Status") EndIf Local $location, $L, $device, $d $location = IniReadSectionNames(@UserName & "\devices.ini") If IsArray($location) Then For $L = 1 To $location[0] $device = IniReadSection(@UserName & "\devices.ini", $location[$L]) If IsArray($device) Then For $d = 1 To $device[0][0] Ping($device[$d][1]) If @error Then $status = "OFFLINE" EndIf If Not @error Then $status = "ONLINE" EndIf ; Update the status label ; NEW CODE GUICtrlSetData($statuslabel, " " & $location[$L] & ", " & $device[$d][0] & " = " & $status) FileWrite($statusfile, '' & @CRLF & _ $location[$L] & "," & $device[$d][0] & "," & $status) Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$L] & @CRLF & "Section Number was: " & $L) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIf EndFunc ;==>PingDevices Edited February 19, 2008 by Ealric My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Ealric Posted February 19, 2008 Share Posted February 19, 2008 Updated the post above - you should be able to make use of it now. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
gcue Posted February 19, 2008 Author Share Posted February 19, 2008 thanks for your help!! i cant find where the undeclared variable is.. expandcollapse popupOpt("GUIOnEventMode", 1) #Include <GuiConstants.au3> #Include <Constants.au3> #include <file.au3> If Not FileExists ("\" & @UserName) Then DirCreate(@UserName) EndIf $devicesfile = @UserName & "\devices.ini" If Not FileExists (@UserName & "\devices.ini") Then FileWrite($devicesfile, "[CRGI Trading Room]" &@CRLF & _ "LAO-53-TRADING4-HP4650DN=10.60.21.220" &@CRLF & _ "" &@CRLF & _ "[CWI Trading Room]" &@CRLF & _ "LAO-34-E-CWI-TRADING3-HP4350DTN=10.60.10.223" &@CRLF & _ "HP Digital Sender 9200C=10.60.10.224") EndIf $statusfile = @TempDir & "\status.csv" If FileExists(@TempDir & "\status.csv") Then FileDelete (@TempDir & "\status.csv") EndIf If FileExists(@UserName & "\status.csv") Then FileDelete (@UserName & "\status.csv") EndIf FileWrite($statusfile, "Location, Device, Status") $parent = GUICreate("Device Pinger v0.1", 275, 200) $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Ping Devices",$filemenu) GUICtrlSetOnEvent(-1,"PingDevices") $fileitem = GUICtrlCreateMenuitem ("Edit Device List",$filemenu) GUICtrlSetOnEvent(-1,"EditCSV") $fileitem = GUICtrlCreateMenuitem ("Export Status to CSV",$filemenu) GUICtrlSetOnEvent(-1,"ExportCSV") $viewmenu = GUICtrlCreateMenu("View", -1, 2) $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState($viewstatusitem, $GUI_CHECKED) $helpmenu = GUICtrlCreateMenu ("&Help") $helpitem = GUICtrlCreateMenuitem ("About",$helpmenu) GUICtrlSetOnEvent(-1,"About") GUISetOnEvent($GUI_EVENT_CLOSE, "XButton") $statuslabel = GUICtrlCreateLabel("No Devices Pinged Yet" , 119, 590, 129, 17, BitOR($SS_SIMPLE, $SS_SUNKEN)) ;$background = GUICtrlCreatePic ("pong.jpg", 110, 0, 100, 46) GUISetState(@SW_SHOW) While 1 Sleep(1000) PingDevices() Select Case $msg = $viewstatusitem If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf EndSelect WEnd Func PingDevices() If FileExists(@TempDir & "\status.csv") Then FileDelete (@TempDir & "\status.csv") FileWrite($statusfile, "Location, Device, Status") EndIf Local $location, $L, $device, $d $location = IniReadSectionNames(@UserName & "\devices.ini") If IsArray($location) Then For $L = 1 To $location[0] $device = IniReadSection(@UserName & "\devices.ini", $location[$L]) If IsArray($device) Then For $d = 1 To $device[0][0] Ping($device[$d][1]) If @error Then $status="OFFLINE" EndIf If Not @error Then $status="ONLINE" EndIf GUICtrlSetData($statuslabel, " " & $location[$L] & ", " & $device[$d][0] & " = " & $status) FileWrite($statusfile, '' &@CRLF & _ $location[$L] & "," & $device[$d][0] & "," & $status) Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$L] & @CRLF & "Section Number was: " & $L) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIf EndFunc Func EditCSV() ShellExecute(@UserName & "\devices.ini") EndFunc Func ExportCSV() $csvfile = FileSaveDialog ( "Export CSV", @UserProfileDir & "\Desktop", "Comma Seperated Values (*.csv)", 16) FileCopy(@TempDir & "\status.csv", $csvfile & ".csv", 1) ShellExecute($csvfile & ".csv") EndFunc Func About() MsgBox(262208, "About", 'Device Pinger v0.1'&@CRLF & _ ''&@CRLF & _ 'Pings devices in: ' & @UserName & '\devices.ini'&@CRLF & _ '(You can add as many locations/devices as you want.)'&@CRLF & _ ''&@CRLF & _ 'Contact GXM x90760 for questions/suggestions.') EndFunc Func Xbutton() FileDelete(@TempDir & "\status.csv") Exit EndFunc Updated the post above - you should be able to make use of it now. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 20, 2008 Moderators Share Posted February 20, 2008 Here you go. expandcollapse popupOpt("GUIOnEventMode", 1) #include <GuiConstants.au3> #include <Constants.au3> #include <file.au3> If Not FileExists("\" & @UserName) Then DirCreate(@UserName) EndIf $devicesfile = @UserName & "\devices.ini" If Not FileExists(@UserName & "\devices.ini") Then FileWrite($devicesfile, "[CRGI Trading Room]" & @CRLF & _ "LAO-53-TRADING4-HP4650DN=10.60.21.220" & @CRLF & _ "" & @CRLF & _ "[CWI Trading Room]" & @CRLF & _ "LAO-34-E-CWI-TRADING3-HP4350DTN=10.60.10.223" & @CRLF & _ "HP Digital Sender 9200C=10.60.10.224") EndIf $statusfile = @TempDir & "\status.csv" If FileExists(@TempDir & "\status.csv") Then FileDelete(@TempDir & "\status.csv") EndIf If FileExists(@UserName & "\status.csv") Then FileDelete(@UserName & "\status.csv") EndIf FileWrite($statusfile, "Location, Device, Status") $parent = GUICreate("Device Pinger v0.1", 275, 200) $filemenu = GUICtrlCreateMenu("&File") $filepingitem = GUICtrlCreateMenuItem("Ping Devices", $filemenu) GUICtrlSetOnEvent(-1, "PingDevices") $fileedititem = GUICtrlCreateMenuItem("Edit Device List", $filemenu) GUICtrlSetOnEvent(-1, "EditCSV") $fileexportitem = GUICtrlCreateMenuItem("Export Status to CSV", $filemenu) GUICtrlSetOnEvent(-1, "ExportCSV") $viewmenu = GUICtrlCreateMenu("View", -1, 2) $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState($viewstatusitem, $GUI_CHECKED) $helpmenu = GUICtrlCreateMenu("&Help") $helpitem = GUICtrlCreateMenuItem("About", $helpmenu) GUICtrlSetOnEvent(-1, "About") GUISetOnEvent($GUI_EVENT_CLOSE, "XButton") $statuslabel = GUICtrlCreateLabel("No Devices Pinged Yet",0,160,275,20,BitOR($SS_SIMPLE,$SS_SUNKEN)) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Sleep(0300) Select Case $msg = $viewstatusitem If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf Case $msg = $filepingitem PingDevices() Case $msg = $fileedititem EditCSV() Case $msg = $fileexportitem ExportCSV() Case $msg = $helpitem About() Case $msg = $GUI_EVENT_CLOSE Xbutton() EndSelect WEnd Func PingDevices() If FileExists(@TempDir & "\status.csv") Then FileDelete(@TempDir & "\status.csv") FileWrite($statusfile, "Location, Device, Status") EndIf Local $location, $L, $device, $d $location = IniReadSectionNames(@UserName & "\devices.ini") If IsArray($location) Then For $L = 1 To $location[0] $device = IniReadSection(@UserName & "\devices.ini", $location[$L]) If IsArray($device) Then For $d = 1 To $device[0][0] Ping($device[$d][1]) If @error Then $status = "OFFLINE" EndIf If Not @error Then $status = "ONLINE" EndIf GUICtrlSetData($statuslabel, " " & $location[$L] & ", " & $device[$d][0] & " = " & $status) FileWrite($statusfile, '' & @CRLF & _ $location[$L] & "," & $device[$d][0] & "," & $status) Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$L] & @CRLF & "Section Number was: " & $L) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIf EndFunc ;==>PingDevices Func EditCSV() ShellExecute(@UserName & "\devices.ini") EndFunc ;==>EditCSV Func ExportCSV() $csvfile = FileSaveDialog("Export CSV", @UserProfileDir & "\Desktop", "Comma Seperated Values (*.csv)", 16) FileCopy(@TempDir & "\status.csv", $csvfile & ".csv", 1) ShellExecute($csvfile & ".csv") EndFunc ;==>ExportCSV Func About() MsgBox(262208, "About", 'Device Pinger v0.1' & @CRLF & _ '' & @CRLF & _ 'Pings devices in: ' & @UserName & '\devices.ini' & @CRLF & _ '(You can add as many locations/devices as you want.)' & @CRLF & _ '' & @CRLF & _ 'Contact GXM x90760 for questions/suggestions.') EndFunc ;==>About Func Xbutton() FileDelete(@TempDir & "\status.csv") Exit EndFunc ;==>XbuttonUm... You may have fixed the undeclared variable, but you haven't fixed an issue of not being able to use GUIGetMsg() and GUIOnEventMode together Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Ealric Posted February 20, 2008 Share Posted February 20, 2008 (edited) Here, use this instead: expandcollapse popup#include <GuiConstants.au3> #include <Constants.au3> #include <file.au3> If Not FileExists("\" & @UserName) Then DirCreate(@UserName) EndIf $devicesfile = @UserName & "\devices.ini" If Not FileExists(@UserName & "\devices.ini") Then FileWrite($devicesfile, "[CRGI Trading Room]" & @CRLF & _ "LAO-53-TRADING4-HP4650DN=10.60.21.220" & @CRLF & _ "" & @CRLF & _ "[CWI Trading Room]" & @CRLF & _ "LAO-34-E-CWI-TRADING3-HP4350DTN=10.60.10.223" & @CRLF & _ "HP Digital Sender 9200C=10.60.10.224") EndIf $statusfile = @TempDir & "\status.csv" If FileExists(@TempDir & "\status.csv") Then FileDelete(@TempDir & "\status.csv") EndIf If FileExists(@UserName & "\status.csv") Then FileDelete(@UserName & "\status.csv") EndIf FileWrite($statusfile, "Location, Device, Status") $parent = GUICreate("Device Pinger v0.1", 275, 200) $filemenu = GUICtrlCreateMenu("&File") $filepingitem = GUICtrlCreateMenuItem("Ping Devices", $filemenu) $fileedititem = GUICtrlCreateMenuItem("Edit Device List", $filemenu) $fileexportitem = GUICtrlCreateMenuItem("Export Status to CSV", $filemenu) $viewmenu = GUICtrlCreateMenu("View", -1, 2) $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState($viewstatusitem, $GUI_CHECKED) $helpmenu = GUICtrlCreateMenu("&Help") $helpitem = GUICtrlCreateMenuItem("About", $helpmenu) $statuslabel = GUICtrlCreateLabel("No Devices Pinged Yet",0,160,275,20,BitOR($SS_SIMPLE,$SS_SUNKEN)) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $viewstatusitem If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf Case $msg = $filepingitem PingDevices() Case $msg = $fileedititem EditCSV() Case $msg = $fileexportitem ExportCSV() Case $msg = $helpitem About() Case $msg = $GUI_EVENT_CLOSE Xbutton() EndSelect WEnd Func PingDevices() If FileExists(@TempDir & "\status.csv") Then FileDelete(@TempDir & "\status.csv") FileWrite($statusfile, "Location, Device, Status") EndIf Local $location, $L, $device, $d $location = IniReadSectionNames(@UserName & "\devices.ini") If IsArray($location) Then For $L = 1 To $location[0] $device = IniReadSection(@UserName & "\devices.ini", $location[$L]) If IsArray($device) Then For $d = 1 To $device[0][0] Ping($device[$d][1]) If @error Then $status = "OFFLINE" EndIf If Not @error Then $status = "ONLINE" EndIf GUICtrlSetData($statuslabel, " " & $location[$L] & ", " & $device[$d][0] & " = " & $status) FileWrite($statusfile, '' & @CRLF & _ $location[$L] & "," & $device[$d][0] & "," & $status) Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$L] & @CRLF & "Section Number was: " & $L) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIf EndFunc ;==>PingDevices Func EditCSV() ShellExecute(@UserName & "\devices.ini") EndFunc ;==>EditCSV Func ExportCSV() $csvfile = FileSaveDialog("Export CSV", @UserProfileDir & "\Desktop", "Comma Seperated Values (*.csv)", 16) FileCopy(@TempDir & "\status.csv", $csvfile & ".csv", 1) ShellExecute($csvfile & ".csv") EndFunc ;==>ExportCSV Func About() MsgBox(262208, "About", 'Device Pinger v0.1' & @CRLF & _ '' & @CRLF & _ 'Pings devices in: ' & @UserName & '\devices.ini' & @CRLF & _ '(You can add as many locations/devices as you want.)' & @CRLF & _ '' & @CRLF & _ 'Contact GXM x90760 for questions/suggestions.') EndFunc ;==>About Func Xbutton() FileDelete(@TempDir & "\status.csv") Exit EndFunc ;==>Xbutton My suggestions are: Make your GUI a little larger horizontally to fit a standard device type return status. Create and assign multiple labels to the type of information you are trying to return - right now all I've included is just one example label. Last, your PingDevices function will create an "executable has changed" response with most good AV software packages like kaspersky, bit defender, etc. Otherwise, unless you are planning on performing very lengthy data polling, no need to use OnEvents. Intra-network pinging won't take long at all. If you are planning on pinging out of network, then perhaps it would be more efficient and usable to keep OnEvents working. Anyhoo, that's just my opinion - others may not agree. To each his/her own. Edited February 20, 2008 by Ealric My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Ealric Posted February 20, 2008 Share Posted February 20, 2008 I'm going to fix the code for you the way I would do it - just driving me nuts looking at it. My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
Ealric Posted February 20, 2008 Share Posted February 20, 2008 (edited) This should do it for you. It supports up to 10 devices. You can alter that easily by having it read an .ini file and then decide how many devices it supports. It's using listview which is in fact better for the type of info you are wanting to display. At the beginning of ping, it will clear the list and then populate the list. The columns can be sized and you can look up the functions to figure out how they work in detail so you can add more to it. Enjoy. expandcollapse popup#include <GuiConstants.au3> #include <Constants.au3> #include <file.au3> Global $statuslabelitem[10] If Not FileExists("\" & @UserName) Then DirCreate(@UserName) EndIf $devicesfile = @UserName & "\devices.ini" If Not FileExists(@UserName & "\devices.ini") Then FileWrite($devicesfile, "[CRGI Trading Room]" & @CRLF & _ "LAO-53-TRADING4-HP4650DN=10.60.21.220" & @CRLF & _ "" & @CRLF & _ "[CWI Trading Room]" & @CRLF & _ "LAO-34-E-CWI-TRADING3-HP4350DTN=10.60.10.223" & @CRLF & _ "HP Digital Sender 9200C=10.60.10.224") EndIf $statusfile = @TempDir & "\status.csv" If FileExists(@TempDir & "\status.csv") Then FileDelete(@TempDir & "\status.csv") EndIf If FileExists(@UserName & "\status.csv") Then FileDelete(@UserName & "\status.csv") EndIf FileWrite($statusfile, "Location, Device, Status") $parent = GUICreate("Device Pinger v0.1", 450, 250) $filemenu = GUICtrlCreateMenu("&File") $filepingitem = GUICtrlCreateMenuItem("Ping Devices", $filemenu) $fileedititem = GUICtrlCreateMenuItem("Edit Device List", $filemenu) $fileexportitem = GUICtrlCreateMenuItem("Export Status to CSV", $filemenu) $viewmenu = GUICtrlCreateMenu("View", -1, 2) $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState($viewstatusitem, $GUI_CHECKED) $helpmenu = GUICtrlCreateMenu("&Help") $helpitem = GUICtrlCreateMenuItem("About", $helpmenu) $statuslabel = GUICtrlCreateListView("Location|Device|Status",0,0,450,230) For $i = 0 to 9 step 1 $statuslabelitem[$i] = GUICtrlCreateListViewItem(" | | ",$statuslabel) Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $viewstatusitem If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf Case $msg = $filepingitem PingDevices() Case $msg = $fileedititem EditCSV() Case $msg = $fileexportitem ExportCSV() Case $msg = $helpitem About() Case $msg = $GUI_EVENT_CLOSE Xbutton() EndSelect WEnd Func PingDevices() For $i = 0 to 9 GUICtrlSetData($statuslabelitem[$i]," | | ") Next If FileExists(@TempDir & "\status.csv") Then FileDelete(@TempDir & "\status.csv") FileWrite($statusfile, "Location, Device, Status") EndIf Local $location, $L, $device, $d, $i=0 $location = IniReadSectionNames(@UserName & "\devices.ini") If IsArray($location) Then For $L = 1 To $location[0] $device = IniReadSection(@UserName & "\devices.ini", $location[$L]) If IsArray($device) Then For $d = 1 To $device[0][0] Ping($device[$d][1]) If @error Then $status = "OFFLINE" EndIf If Not @error Then $status = "ONLINE" EndIf GUICtrlSetData($statuslabelitem[$i],$location[$L] & "|" & $device[$d][0] & "|" & $status) FileWrite($statusfile, '' & @CRLF & _ $location[$L] & "," & $device[$d][0] & "," & $status) $i = $i + 1 Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$L] & @CRLF & "Section Number was: " & $L) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIf EndFunc ;==>PingDevices Func EditCSV() ShellExecute(@UserName & "\devices.ini") EndFunc ;==>EditCSV Func ExportCSV() $csvfile = FileSaveDialog("Export CSV", @UserProfileDir & "\Desktop", "Comma Seperated Values (*.csv)", 16) FileCopy(@TempDir & "\status.csv", $csvfile & ".csv", 1) ShellExecute($csvfile & ".csv") EndFunc ;==>ExportCSV Func About() MsgBox(262208, "About", 'Device Pinger v0.1' & @CRLF & _ '' & @CRLF & _ 'Pings devices in: ' & @UserName & '\devices.ini' & @CRLF & _ '(You can add as many locations/devices as you want.)' & @CRLF & _ '' & @CRLF & _ 'Contact GXM x90760 for questions/suggestions.') EndFunc ;==>About Func Xbutton() FileDelete(@TempDir & "\status.csv") Exit EndFunc ;==>Xbutton Edited February 20, 2008 by Ealric My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic] Link to comment Share on other sites More sharing options...
gcue Posted February 20, 2008 Author Share Posted February 20, 2008 wow.. thank you so much for investing the time =) looks great! thanks again. Link to comment Share on other sites More sharing options...
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