CyNDeR Posted January 13, 2008 Share Posted January 13, 2008 I'm creating a small GUI ping utility that will ping a url/ip at a set interval and display the results on the GUI. I just can't figure out what type of GUI element to use to display the result. I'd like to have it store like the last 25 ping results. How would i go about doing this? My scripts: Random Painter Link to comment Share on other sites More sharing options...
CyNDeR Posted January 13, 2008 Author Share Posted January 13, 2008 Figured out how to use a listbox to do it. Is there a better way? My scripts: Random Painter Link to comment Share on other sites More sharing options...
weaponx Posted January 13, 2008 Share Posted January 13, 2008 Plain text edit box. Link to comment Share on other sites More sharing options...
FreeFry Posted January 13, 2008 Share Posted January 13, 2008 or use a label Link to comment Share on other sites More sharing options...
CyNDeR Posted January 14, 2008 Author Share Posted January 14, 2008 Now i feel stupid, lol. Can't figure out why it's not working, so here is my code so far: #Include <GUIConstants.au3> GUICreate("Pingy", 313, 232, 193, 125) GUICtrlCreateLabel("++ Website/IP to ping.++", 40, 8, 131, 17) $PingCount = 0 $URL = GUICtrlCreateInput("", 16, 32, 185, 21) $StartPing = GUICtrlCreateButton("Ping!", 32, 64, 145, 57, 0) $Results = GUICtrlCreateLabel("", 224, 40, 81, 177, $SS_BLACKFRAME) $StopPing = GUICtrlCreateButton("Stop!", 32, 142, 145, 57, 0) $PingCounter = GUICtrlCreateLabel("Ping Count: " & $PingCount, 224, 8, 80, 17) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $StartPing For $i = 1 To 5 $Pinging = Ping($URL) GUICtrlSetData($Results, "TTL: " & $Pinging) $PingCount = $PingCount + 1 GUICtrlSetData($PingCounter, "Ping Count: " & $PingCount) Next EndSwitch WEnd A few problems. The $Results label doesnt work, the GUI is very sluggish, and i can't figure out how to get the stop button to work correctly. It's been awhile since i've even seen AutoIt code so i'm sure i'm just missing something stupid. My scripts: Random Painter Link to comment Share on other sites More sharing options...
rasim Posted January 14, 2008 Share Posted January 14, 2008 (edited) Try this: expandcollapse popup#Include <GUIConstants.au3> GUICreate("Pingy", 313, 232, 193, 125) GUICtrlCreateLabel("++ Website/IP to ping.++", 40, 8, 131, 17) Dim $PingCount = 0 $URL = GUICtrlCreateInput("", 16, 32, 185, 21) $StartPing = GUICtrlCreateButton("Ping!", 32, 64, 145, 57, 0) $group = GUICtrlCreateGroup("Result", 224, 25, 81, 177, $BS_CENTER) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($group), "wstr", "", "wstr", "") $Results = GUICtrlCreateLabel("", 229, 50, 70, 17) GUICtrlSetFont(-1, Default, 800) GUICtrlSetColor(-1, 0x008000) $StopPing = GUICtrlCreateButton("Stop!", 32, 142, 145, 57, 0) $PingCounter = GUICtrlCreateLabel("Ping Count: " & $PingCount, 224, 8, 80, 17) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $StartPing _Ping() EndSwitch WEnd Func _Ping() Local $Pinging, $i For $i = 1 To 5 $Pinging = Ping(GUICtrlRead($URL)) If GUIGetMsg() = $StopPing Then Return 0 GUICtrlSetData($Results, "TTL: " & $Pinging) $PingCount = $PingCount + 1 GUICtrlSetData($PingCounter, "Ping Count: " & $PingCount) Next EndFunc Edited January 14, 2008 by rasim Link to comment Share on other sites More sharing options...
CyNDeR Posted January 15, 2008 Author Share Posted January 15, 2008 Thanks! It works good except for a couple things. First, i'd like to display the result of each ping in a list of sorts, not just display the last result. Also, for some reason the Ping Counter doesnt reset when the start button is pressed. I'd like to write the code myself, if you could just point me in the right direction. My scripts: Random Painter Link to comment Share on other sites More sharing options...
rasim Posted January 15, 2008 Share Posted January 15, 2008 Like this? expandcollapse popup#include <GUIConstants.au3> #include <GuiListBox.au3> $hGui = GUICreate("Pingy", 313, 232, 193, 125) GUICtrlCreateLabel("++ Website/IP to ping.++", 40, 8, 131, 17) Dim $PingCount = 0 $URL = GUICtrlCreateInput("", 16, 32, 185, 21) $StartPing = GUICtrlCreateButton("Ping!", 32, 64, 145, 57, 0) $StopPing = GUICtrlCreateButton("Stop!", 32, 142, 145, 57, 0) $PingCounter = GUICtrlCreateLabel("Ping Count: " & $PingCount, 224, 8, 80, 17) $ClearButton = GUICtrlCreateButton("Clear", 224, 210, 81, 20) $hListBox = _GUICtrlListBox_Create($hGui, "", 224, 32, 81, 182, BitOR($WS_VSCROLL, $LBS_NOSEL)) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $StartPing If GUICtrlRead($URL) = '' Then MsgBox(16, "Error", "Please type web address") GUICtrlSetState($URL, $GUI_FOCUS) ContinueCase EndIf _Ping() Case $ClearButton If _GUICtrlListBox_GetCount($hListBox) > 0 Then _GUICtrlListBox_ResetContent($hListBox) GUICtrlSetData($PingCounter, "Ping Count: 0") $PingCount = 0 EndIf EndSwitch WEnd Func _Ping() Local $Pinging, $i For $i = 1 To 5 $Pinging = Ping(GUICtrlRead($URL)) If GUIGetMsg() = $StopPing Then Return 0 _GUICtrlListBox_AddString($hListBox, $Pinging) $PingCount += 1 GUICtrlSetData($PingCounter, "Ping Count: " & $PingCount) Next EndFunc 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