Razormaul Posted June 29, 2015 Posted June 29, 2015 (edited) This is a repost, since the thread was deleted due to database issues. - https://www.autoitscript.com/forum/topic/173518-thread-deleted/ Hello fellow geeksI am making a small program for work, a tool with shortcuts and host monitoring.The program has several tab and I need help with the tab called "Servers/Hosts"The tab reads hostnames or ip adresses from an ini file and writes them to a listview. You can add or remove hosts, ping, connect with mstsc and delete the whole list. Now...Im checking for ip adresses on start of the program, or with a refresh button - so far so good.. It´s working.I also have a function to check if a host is online and write it to the listview, but i cant make it work (im not good enough yet) - (ALMOST SOLVED - Writing a dummyhost e.g. "test" as hostname, gets the status "Online" - im currently working on that )This check needs to run every 10 seconds or so, among with the check for ip adresses. But again, (im not good enough yet) - (SOLVED USING AdlibRegister)I´ve tried to put the functions in a loop in different places in the script. They either "block" the script or hide it.If i can get the loop to work, there is no need for a refresh button. and i want to put the foldercheck in the VIKING tab in a similar loop, displaying a warning instead of having to click a button. (but thats a different question)I hope one of you briliant minds can help me along the way:) Thank you for your time.Tobias IT-Tools.V13.au3 Servers.ini Edited June 29, 2015 by Razormaul updated files Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty!
Razormaul Posted June 29, 2015 Author Posted June 29, 2015 Thanks to Venix https://www.autoitscript.com/forum/profile/71162-venix/ for helping witih the repeating functions. Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty!
Venix Posted June 29, 2015 Posted June 29, 2015 (edited) Are you still struggling with any part of this script? It looks functional to me.Edit: Other than the fact of it being difficult to close because of the constant refreshing of the ping command. Edited June 29, 2015 by Venix
Razormaul Posted June 29, 2015 Author Posted June 29, 2015 (edited) OK, this is starting to get annoing Last 2 replies is now gone! (I know your updating)The issue is getting the corret status from a ping to a listview.I´ve done many different things with If, If Else statements. I´ve also tried Switch Case:expandcollapse popup; GET STATUS OF HOST: OFFLINE / ONLINE AND WRITE TO LISTVIEW ########==> Func GetStatus() Local $iniRead = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") For $i = 0 To $iniRead[0][0] $Ip = $iniRead[$i][1] Local $iPing = Ping($Ip, 2000) ;MsgBox(0, "$Ip = ", $Ip) ;MsgBox(0, "@error", @Error) If $iPing > 0 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Online", 2) If @error = 1 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Offline", 2) If @error = 2 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Unreachable", 2) If @error = 3 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Bad Destination", 2) If @error = 4 Then _GUICtrlListView_AddSubItem($listview_srv, $i, "Error", 2) If $Ip = "" Then _GUICtrlListView_AddSubItem($listview_srv, $i, "IP Missing", 2) EndIf EndIf EndIf EndIf EndIf EndIf Next EndFuncAnd the Case: Switch $iPing Case $iPing > 0 _GUICtrlListView_AddSubItem($listview_srv, $i, "Online", 2) Case Else @error = 1 _GUICtrlListView_AddSubItem($listview_srv, $i, "Offline", 2) Case Else @error = 2 _GUICtrlListView_AddSubItem($listview_srv, $i, "Unreachable", 2) Case Else @error = 3 _GUICtrlListView_AddSubItem($listview_srv, $i, "Bad Destination", 2) Case Else @error = 4 _GUICtrlListView_AddSubItem($listview_srv, $i, "Error", 2) Case Else $Ip = "" _GUICtrlListView_AddSubItem($listview_srv, $i, "IP Missing", 2) EndSwitchIm currently working on the updating problem (GUI is unresponsive while the functions are running) Edited June 29, 2015 by Razormaul Oh, my God. They found me. I don't know how, but they found me. Run for it, Marty!
Venix Posted June 29, 2015 Posted June 29, 2015 (edited) @RazormaulIll take a look at this when I get home tonight, assuming I don't forget. The GUI will be unresponsive whilst functions are running because AutoIT is a single threaded language. Unfortunately as your function takes a while to run this will cause the GUI to hang which is undesirable. Some fellow users might have some suggestions about how you can handle such problems more elegantly. One thing you could do is handle all the pinging with a completely separate script and then that script could output the necessary data to a file. And then every 30 seconds or so your script can pull in the new information from the file.Edit: I wouldn't necessary say this Is a great solution but you have to work with the boundaries of a single thread. Edited June 29, 2015 by Venix
Venix Posted June 29, 2015 Posted June 29, 2015 Does this work for you?; GET STATUS OF HOST: OFFLINE / ONLINE AND WRITE TO LISTVIEW ########==> Func GetStatus() Local $iniRead = IniReadSection (@ScriptDir & "\Servers.ini", "Servers") For $i = 0 To $iniRead[0][0] Local $Ip = $iniRead[$i][1] Local $iPing = Ping($Ip, 2000) Local $error = @error Select Case $iPing > 0 _GUICtrlListView_AddSubItem($listview_srv, $i, "Online", 2) Case $error = 1 _GUICtrlListView_AddSubItem($listview_srv, $i, "Offline", 2) Case $error = 2 _GUICtrlListView_AddSubItem($listview_srv, $i, "Unreachable", 2) Case $error = 3 _GUICtrlListView_AddSubItem($listview_srv, $i, "Bad Destination", 2) Case Else _GUICtrlListView_AddSubItem($listview_srv, $i, "Other", 2) EndSelect Next EndFunc
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