KamilZajaczkowski Posted December 4, 2012 Share Posted December 4, 2012 Hi there, I need some help with below script: expandcollapse popup#NoTrayIcon #include #include #include #Include HotKeySet("{ESC}", "_hkExitApp") $hWnd = GUICreate("Form1", 300, 300, 500, 500) GUISetBkColor(0xABABAB) ; pozycja lp, pozycja gd , szerokosc, wysokosc $Progress1 = "" $Progress2 = "" $Progress3 = "" #Region ### START Koda GUI section ### Form=C:\Users\kzajaczkowski\Desktop\Status.kxf $hWnd = GUICreate("Ping", 428, 155, 254, 124) $Hostname1 = GUICtrlCreateInput("ppuk_it05", 24, 24, 265, 21) $Status1 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Yellow.ico", -1, 336, 16, 32, 32) $Hostname2 = GUICtrlCreateInput("ppwl_fps01", 24, 64, 265, 21) $Status2 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Yellow.ico", -1, 336, 56, 32, 32) $Hostname3 = GUICtrlCreateInput("10.128.44.254", 24, 104, 265, 21) $Status3 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Yellow.ico", -1, 336, 96, 32, 32) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Do Global $sURL= GUICtrlRead($Hostname1) Global $sURL2= GUICtrlRead($Hostname2) Global $sURL3= GUICtrlRead($Hostname3) $iPing = Ping($sURL, 999) $iPing2 = Ping($sURL2, 999) $iPing3 = Ping($sURL3, 999) Select Case $iPing2 = 0 $Progress2 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Red.ico", -1, 336, 56, 32, 32) Sleep(500) Case $iPing2 < 999 $Progress2 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Green.ico", -1, 336, 56, 32, 32) Sleep(500) EndSelect Select Case $iPing = 0 $Progress1 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Red.ico", -1, 336, 16, 32, 32) Sleep(500) Case $iPing < 999 $Progress1 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Green.ico", -1, 336, 16, 32, 32) Sleep(500) EndSelect Select Case $iPing3 = 0 $Progress3 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Red.ico", -1, 336, 96, 32, 32) Sleep(500) Case $iPing3 < 999 $Progress3 = GUICtrlCreateIcon("C:\Users\kzajaczkowski\Desktop\Green.ico", -1, 336, 96, 32, 32) Sleep(500) EndSelect Until GUIGetMsg()=$GUI_EVENT_CLOSE Func _hkExitApp() Exit EndFunc It does ping whatever is in input fields and then changes icon from default to RED/GREEN depending on ping result. I need help with one part however, I can't figure out how to make X (close) Window button to close that form! Please let me know how this can be archived! Link to comment Share on other sites More sharing options...
Andreik Posted December 4, 2012 Share Posted December 4, 2012 You need to ping these hosts continuous? This is what makes your window almost impossible to use. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Chance Posted December 4, 2012 Share Posted December 4, 2012 I personally think you should do it more like this. The AutoIt code at least Ping UI.rar Link to comment Share on other sites More sharing options...
Exit Posted December 4, 2012 Share Posted December 4, 2012 #include <GUIConstantsEx.au3> HotKeySet("{ESC}", "_hkExitApp") $hWnd = GUICreate("Ping", 428, 155, 254, 124) GUISetBkColor(0xABABAB) $Hostname1 = GUICtrlCreateInput("google.com", 64, 24, 265, 21) $Hostname2 = GUICtrlCreateInput("facebook.com", 64, 64, 265, 21) $Hostname3 = GUICtrlCreateInput("autoitscript.com", 64, 104, 265, 21) $Status1 = GUICtrlCreateIcon("shell32.dll", -145, 20, 20) $Status2 = GUICtrlCreateIcon("shell32.dll", -145, 20, 60) $Status3 = GUICtrlCreateIcon("shell32.dll", -145, 20, 100) GUISetState(@SW_SHOW) Do Sleep(100) If Ping(GUICtrlRead($Hostname1)) Then GUICtrlSetImage($Status1, "shell32.dll", -145) Else GUICtrlSetImage($Status1, "shell32.dll", -132) EndIf If Ping(GUICtrlRead($Hostname2)) Then GUICtrlSetImage($Status2, "shell32.dll", -145) Else GUICtrlSetImage($Status2, "shell32.dll", -132) EndIf If Ping(GUICtrlRead($Hostname3)) Then GUICtrlSetImage($Status3, "shell32.dll", -145) Else GUICtrlSetImage($Status3, "shell32.dll", -132) EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _hkExitApp() Exit EndFunc ;==>_hkExitApp App: Au3toCmd       UDF: _SingleScript()                 Link to comment Share on other sites More sharing options...
Chance Posted December 4, 2012 Share Posted December 4, 2012 (edited) #include <GUIConstantsEx.au3> HotKeySet("{ESC}", "_hkExitApp") $hWnd = GUICreate("Ping", 428, 155, 254, 124) GUISetBkColor(0xABABAB) $Hostname1 = GUICtrlCreateInput("google.com", 64, 24, 265, 21) $Hostname2 = GUICtrlCreateInput("facebook.com", 64, 64, 265, 21) $Hostname3 = GUICtrlCreateInput("autoitscript.com", 64, 104, 265, 21) $Status1 = GUICtrlCreateIcon("shell32.dll", -145, 20, 20) $Status2 = GUICtrlCreateIcon("shell32.dll", -145, 20, 60) $Status3 = GUICtrlCreateIcon("shell32.dll", -145, 20, 100) GUISetState(@SW_SHOW) Do Sleep(100) If Ping(GUICtrlRead($Hostname1)) Then GUICtrlSetImage($Status1, "shell32.dll", -145) Else GUICtrlSetImage($Status1, "shell32.dll", -132) EndIf If Ping(GUICtrlRead($Hostname2)) Then GUICtrlSetImage($Status2, "shell32.dll", -145) Else GUICtrlSetImage($Status2, "shell32.dll", -132) EndIf If Ping(GUICtrlRead($Hostname3)) Then GUICtrlSetImage($Status3, "shell32.dll", -145) Else GUICtrlSetImage($Status3, "shell32.dll", -132) EndIf Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _hkExitApp() Exit EndFunc ;==>_hkExitApp I think it would be a little better to reduce the ping requests to a few seconds. also, It seems a little odd to ping a few servers that fast and in a loop. Especially in a loop like that will prevent the gui from working right, like not reacting to user input if one of the servers it's pinging is off line because it's waiting for the request. it's just going to freeze AutoIts thread, and it'll have the same effect as the script in the the op is having problems with. Edited December 4, 2012 by FlutterShy Link to comment Share on other sites More sharing options...
JScript Posted December 4, 2012 Share Posted December 4, 2012 I think this code is authored by trancexx:Download: PingInAnotherThread.au3JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
Chance Posted December 4, 2012 Share Posted December 4, 2012 (edited) Here's another little nice trick to handle user input. Say you start the script, itll ping some default entris after you stop typing the address for 3 seconds or press enter on any of the boxes, you can leave a box empty, it won't try pinging a null value I also copy pasted an addressbar to show status. Ping UI.rar I think this code is authored by trancexx: Download: PingInAnotherThread.au3 JS I was thinking about that, but it only pings one address And yeas, trancexx made that Edited December 4, 2012 by FlutterShy Link to comment Share on other sites More sharing options...
zaqimon Posted December 5, 2012 Share Posted December 5, 2012 (edited) I make use of ping.exe and a temp file for non-blocking ping. You can use AdlibRegister and the ping should not block your UI If $ping_ok = 0, ping failed. $ping_ok = FileGetSize(@TempDir & "autoit_ping.log") ShellExecute('cmd',' /c type nul>%temp%autoit_ping.log & ping -w 999 -n 1 www.google.com && echo OK>%temp%autoit_ping.log',"","",@SW_HIDE) Edited December 5, 2012 by meltice 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