Swe-Anders Posted October 2, 2022 Posted October 2, 2022 Hi! I have a script that is 2500 rows right now. I made it into 59 rows now so it's more easier to see. The script is an App installer - so you check 1-20 checkboxes and select "Install" and the apps starts installing. To this program I added a clock (that shows HH:MM:SS). I have removed everything except for SS (seconds) so it's easier to see. I also added a ping request that shows the time in milliseconds. I added the ping request because the "File exists" is so slow when it's to a network folder that is not found... So therefore - if the ping request fails, then it won't even bother to try and find the file. In the example it only points to C-drive though. The problem now is that the clock is updating every 100ms (I had to do it that often, because if I changed to 500ms, the program for some reason would be very slow to exit?)... But this also means that the ping will be sent every 100ms, and that's not what I want... The ping could be sent every 1-10 seconds or whatever - but it shouldn't ddos attack the server I've tried and experiment with Adlibregister (but to be honest, I'm really awful in understanding that command) but I can't seem to figure it out... What should I do so that: The clock is updated every 100-500ms. Ping is sent every 1-10 seconds. Exiting the program is quick. I can still use the button "Install" to install the programs (but in this example all it does is a message box ofcourse). Thank you for your recommendations expandcollapse popup#RequireAdmin #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <File.au3> #include <TrayConstants.au3> #include <ColorConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1_1 = GUICreate("App installer", 1300, 637, -1, -1) Global $Button1 = GUICtrlCreateButton("Install", 15, 501, 155, 25) Global $AccessKnown = 0, $iniValue, $Label21 = GUICtrlCreateLabel("Access: ?", 1180, 10, 275, 20) $Lbl7 = GUICtrlCreateLabel("SS", 583, 600, 30, 61, $SS_CENTER) Global $PingLabel = GUICtrlCreateLabel("Ping", 1100, 10, 75, 24) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 GUICtrlSetData($Lbl7, _Seconds()) Sleep(100) Global $PingServer = Ping ('192.168.1.1', 1000) If $PingServer Then GuiCtrlSetData ($PingLabel, 'Ping: ' & $PingServer & 'ms') Global $FileExists = FileExists ('C:/Hello/Hello.txt') If $FileExists = 1 Then GUICtrlSetData($Label21, "Access: Yes") $AccessKnown = 1 Else GUICtrlSetData($Label21, "Access: No") $AccessKnown = 0 EndIf Else GuiCtrlSetData ($PingLabel, 'Ping: ---') GUICtrlSetData($Label21, "Access: No") $AccessKnown = 0 EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox (0, "Hello", "Hello world") EndSwitch WEnd Func _Seconds() $ss = (@SEC) Return $ss EndFunc
argumentum Posted October 3, 2022 Posted October 3, 2022 (edited) look into _Timer_SetTimer() for the time thing and IPC ( a few in my signature ) to have a more fluid, unblocked and responsive script. Edited October 3, 2022 by argumentum english, right ? =P Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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