Clipper34 Posted June 12, 2008 Posted June 12, 2008 Hey guys, i've started on a little project over the month and you can ping different addresses and some TCP options. And you view them in a large list. But the problem i'm having is how can you append more pings to the list you have created in the GUI, here's the code i'm working on currently: expandcollapse popup;Varible to tcp connect $connect = @LogonServer ;First ping $ping = InputBox("Desired Host", "Type the desired hostname:") $ping1 = Ping($ping) If @error Then MsgBox(4096, "ERROR", "Please type a hostname to continue, if you wish to quit please type 'exit'") EndIf ;Second ping $ping2 = InputBox("Desired Host", "Type the 2nd desired hostname:") $ping3 = Ping($ping2) If @error Then MsgBox(4096, "ERROR", "Please type a hostname to continue, if you wish to quit please type 'exit'") EndIf ;Third ping $ping4 = InputBox("Desired Host", "Type the 3rd desired hostname:") $ping5 = Ping($ping4) ;If no input in the input box a mesage shows If @error Then MsgBox(4096, "ERROR", "Please type a hostname to continue, if you wish to quit please type 'exit'") EndIf ;Set the 'exit' part If $ping = "exit" Then Exit EndIf ;Include the Constants #include <GuiConstants.au3> ;Create the GUI GUICreate("Ping Check Pro") ;Set the icon GUISetIcon(@Systemdir, "cmd.exe") ;List showing the Pings $listView = GuiCtrlCreateListView("Ping", 1, 15, 200, 200) GuiCtrlCreateListViewItem($ping1, $listView) GUICtrlCreateListViewItem($ping3, $listview) GUICtrlCreateListViewItem($ping5, $listview) ;List showing TCP connections $tcp = GUICtrlCreateListView("TCP Connected to", 200, 15, 200, 200) $tcpitem = GUICtrlCreateListViewItem($connect, $tcp) ;Create the file menu to quit $quitmenu = GUICtrlCreateMenu("Quit") $quitmenuitem = GUICtrlCreateMenuItem("Quit Ping Check Pro", $quitmenu) ;TCP options menu $tcpmenu = GUICtrlCreateMenu("TCP Options") $tcpmenuitem = GUICtrlCreateMenuItem("TCP Connect", $tcpmenu) $tcpmenuitem1 = GUICtrlCreateMenuItem("TCP Disconect", $tcpmenu) $tcpmenuitem2 = GUICtrlCreateMenuItem("TCP Listen", $tcpmenu) $tcpmenuitem3 = GUICtrlCreateMenuItem("TCP Accept", $tcpmenu) $tcpmenuitem4 = GUICtrlCreateMenuItem("TCP Host Name to I.P. Address", $tcpmenu) ;Ping options $pingmenu = GUICtrlCreateMenu("Ping Options") $pingmenuitem = GUICtrlCreateMenuItem("Ping Defined Host", $pingmenu) $pingmenuitem1 = GUICtrlCreateMenuItem("Set Pings", $pingmenu) GUISetState() While 1 $msg = GUIGetMsg() Select ;First case Case $msg = $quitmenuitem Exit ;Second case Case $msg = $tcpmenuitem TCPConnect($connect, 80) $connect1 = InputBox("", "Type a Host Name to connect:") TCPConnect($connect1, 80) ;Third case Case $msg = $tcpmenuitem1 TCPCloseSocket($connect) ;Fourth case Case $msg = $tcpmenuitem2 TCPListen($connect, 80) ;Fifth case Case $msg = $tcpmenuitem3 TCPAccept($connect) ;Sixth case Case $msg = $tcpmenuitem4 $ip = InputBox("", "Type a Host Name to convert to a I.P.") TCPNameToIP($ip) MsgBox(0, "", "The I.P. is:", $ip) ;Seventh case Case $msg = $pingmenuitem $pingm = InputBox("", "Type a Host Name to ping:") Ping($pingm) MsgBox(0, "", "The Ping is:", $pingm Case $msg = $pingmenuitem1 ;First ping $ping = InputBox("Desired Host", "Type the desired hostname:") $ping1 = Ping($ping) If @error Then MsgBox(4096, "ERROR", "Please type a hostname to continue, if you wish to quit please type 'exit'") EndIf ;Second ping $ping2 = InputBox("Desired Host", "Type the 2nd desired hostname:") $ping3 = Ping($ping2) If @error Then MsgBox(4096, "ERROR", "Please type a hostname to continue, if you wish to quit please type 'exit'") EndIf ;Third ping $ping4 = InputBox("Desired Host", "Type the 3rd desired hostname:") $ping5 = Ping($ping4) ;If no input in the input box a mesage shows If @error Then MsgBox(4096, "ERROR", "Please type a hostname to continue, if you wish to quit please type 'exit'") EndIf ;Set the 'exit' part If $ping = "exit" Then Exit EndIf EndSelect WEnd GUIDelete() Any suggestions ideas? Thanks.
enaiman Posted June 13, 2008 Posted June 13, 2008 First: your script wasn't working - you had a syntax error. Please make sure that next time you post something won't have these minor errors. Second: you need to work more on this script - to make the close button to work, and also you need to work on your last Case statement (where I've added a couple comments) I have modified your script a little: at start it will prompt for a host until an empty string is found (nothing typed in the inputbox) and it will put every host in an array ($ping_it). You can see the limit of this array is 250 right now - you can modify that easily. When nothing is entered in the input, the script will continue with the GUI part. Here is the script: expandcollapse popup;Varible to tcp connect $connect = @LogonServer Global $j = 1 Global $ping_it[250] Do $ping = InputBox("Desired Host", "Type the desired hostname:") $ping_it [$j] = Ping($ping) If @error Then MsgBox(4096, "ERROR", "Please type a hostname to continue, if you wish to quit please type 'exit'") Else $j +=1 EndIf Until $ping = "" ;Set the 'exit' part If $ping = "exit" Then Exit EndIf ;Include the Constants #include <GuiConstants.au3> ;Create the GUI GUICreate("Ping Check Pro") ;Set the icon GUISetIcon(@Systemdir, "cmd.exe") ;List showing the Pings $listView = GuiCtrlCreateListView("Ping", 1, 15, 200, 200) For $k = 1 To $j - 1 GuiCtrlCreateListViewItem($ping_it[$k], $listView) Next ;List showing TCP connections $tcp = GUICtrlCreateListView("TCP Connected to", 200, 15, 200, 200) $tcpitem = GUICtrlCreateListViewItem($connect, $tcp) ;Create the file menu to quit $quitmenu = GUICtrlCreateMenu("Quit") $quitmenuitem = GUICtrlCreateMenuItem("Quit Ping Check Pro", $quitmenu) ;TCP options menu $tcpmenu = GUICtrlCreateMenu("TCP Options") $tcpmenuitem = GUICtrlCreateMenuItem("TCP Connect", $tcpmenu) $tcpmenuitem1 = GUICtrlCreateMenuItem("TCP Disconect", $tcpmenu) $tcpmenuitem2 = GUICtrlCreateMenuItem("TCP Listen", $tcpmenu) $tcpmenuitem3 = GUICtrlCreateMenuItem("TCP Accept", $tcpmenu) $tcpmenuitem4 = GUICtrlCreateMenuItem("TCP Host Name to I.P. Address", $tcpmenu) ;Ping options $pingmenu = GUICtrlCreateMenu("Ping Options") $pingmenuitem = GUICtrlCreateMenuItem("Ping Defined Host", $pingmenu) $pingmenuitem1 = GUICtrlCreateMenuItem("Set Pings", $pingmenu) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select ;First case Case $msg = $quitmenuitem Exit ;Second case Case $msg = $tcpmenuitem TCPConnect($connect, 80) $connect1 = InputBox("", "Type a Host Name to connect:") TCPConnect($connect1, 80) ;Third case Case $msg = $tcpmenuitem1 TCPCloseSocket($connect) ;Fourth case Case $msg = $tcpmenuitem2 TCPListen($connect, 80) ;Fifth case Case $msg = $tcpmenuitem3 TCPAccept($connect) ;Sixth case Case $msg = $tcpmenuitem4 $ip = InputBox("", "Type a Host Name to convert to a I.P.") TCPNameToIP($ip) MsgBox(0, "", "The I.P. is:", $ip) ;Seventh case Case $msg = $pingmenuitem $pingm = InputBox("", "Type a Host Name to ping:") Ping($pingm) MsgBox(0, "", "The Ping is:"&$pingm) Case $msg = $pingmenuitem1 ;get the selected element from the list and ping that item ;don't ask the user to specify the host again ;and - you need to change this part; don't only copy-paste from above EndSelect WEnd SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
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