cjconstantine Posted October 12, 2006 Share Posted October 12, 2006 Ok, I did search but didn't find what I was looking for (I'm sorry! Please stop yelling at me!!) ... basically I'm setting up a loop (either a do or a while loop) that I need to exit from when $GUI_EVENT_CLOSE occurs. Here's a rough draft: Func _PingFunction($Server) $gPingWindow = GuiCreate(Something, something, something) $lvPingTime = GuiCtrlCreateListView(blah,blah,blah) GuiSetState(@SW_SHOW,$gPingWindow) Do $iPing = Ping($Server) If $iPing > 0 Then GuiCtrlCreateListViewItem('Ping Time: '&$iPing,$lvPingTime) Else GuiCtrlCreateListViewItem('Timeout',$lvPingTime) Sleep(1000) Until @GUI_CtrlID = $GUI_EVENT_CLOSE EndFunc There is more to the function but I can't exit the loop. Any other opened windows have been disabled and can't receive input. I could work around it using AdlibEnable and call the function every second, but I'd really like to know if using a loop is feasible. OnEvent is properly enabled and all my controls are working up to this point. Link to comment Share on other sites More sharing options...
Valuater Posted October 12, 2006 Share Posted October 12, 2006 Maybe Func _PingFunction($Server) $gPingWindow = GuiCreate(Something, something, something) $lvPingTime = GuiCtrlCreateListView(blah,blah,blah) GuiSetState(@SW_SHOW,$gPingWindow) Do $iPing = Ping($Server) If $iPing > 0 Then GuiCtrlCreateListViewItem('Ping Time: '&$iPing,$lvPingTime) ExitLoop Else GuiCtrlCreateListViewItem('Timeout',$lvPingTime) Sleep(1000) Until @GUI_CtrlID = $GUI_EVENT_CLOSE EndFunc 8) Link to comment Share on other sites More sharing options...
cjconstantine Posted October 12, 2006 Author Share Posted October 12, 2006 (edited) Maybe Func _PingFunction($Server) $gPingWindow = GuiCreate(Something, something, something) $lvPingTime = GuiCtrlCreateListView(blah,blah,blah) GuiSetState(@SW_SHOW,$gPingWindow) Do $iPing = Ping($Server) If $iPing > 0 Then GuiCtrlCreateListViewItem('Ping Time: '&$iPing,$lvPingTime) ExitLoop Else GuiCtrlCreateListViewItem('Timeout',$lvPingTime) Sleep(1000) Until @GUI_CtrlID = $GUI_EVENT_CLOSE EndFunc 8) Wouldn't that just exit the loop after the first successful ping? The script needs to ping the server until the window is closed. Edited October 12, 2006 by cjconstantine Link to comment Share on other sites More sharing options...
xcal Posted October 12, 2006 Share Posted October 12, 2006 Missing an EndIf for 'If $iPing > 0 Then' Not saying that's the problem. Just saying you're missing it. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
cjconstantine Posted October 12, 2006 Author Share Posted October 12, 2006 (edited) Missing an EndIf for 'If $iPing > 0 Then'Not saying that's the problem. Just saying you're missing it. Oops .... minor slip up, I was just retype part of the code from memory :">Oh, and I know the (something, something, something) and (blah, blah, blah) won't work either Edited October 12, 2006 by cjconstantine Link to comment Share on other sites More sharing options...
nfwu Posted October 13, 2006 Share Posted October 13, 2006 Why not don't use OnEvent, then replace this:Until @GUI_CtrlID = $GUI_EVENT_CLOSEoÝ÷ ÛØb±«¢+ØU¹Ñ¥°U%Ñ5Í ¤ôÀÌØíU%}Y9Q} 1=M #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
xcal Posted October 13, 2006 Share Posted October 13, 2006 He said OnEvent was enabled and GuiGetMsg() will only return 0 when it is. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
nfwu Posted October 13, 2006 Share Posted October 13, 2006 Why not don't use OnEvent#) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
xcal Posted October 13, 2006 Share Posted October 13, 2006 Oh sorry, I'm a moron (a lot) sometimes. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
JSThePatriot Posted October 13, 2006 Share Posted October 13, 2006 (edited) I would recommend pinging a certain number of times rather than infinitely until someone closes the window. I just tried something similar, and unless you create a new window just for the ping I dont see this as feasable. Edit: Even with a new window I dont see this as feasable. JS Edited October 13, 2006 by JSThePatriot AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
cjconstantine Posted October 13, 2006 Author Share Posted October 13, 2006 (edited) Why not don't use OnEvent, then replace this:Until @GUI_CtrlID = $GUI_EVENT #) Not use OnEvent ... that would be a lot of code to replace. To JSThePatriot: It does open a new window, typically the program only pings a server every 5 minutes (which can be adjusted if needed). But this will only be used to know if/when a server comes back online after a reboot. I've already written the code using an Adlib function so no loop is required, it just would have been nice Edited October 13, 2006 by cjconstantine 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