Nachico Posted November 22, 2019 Share Posted November 22, 2019 expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> #include <Timers.au3> #Include <Date.au3> #include <GuiEdit.au3> Global $MIN While 1 AdlibRegister("Check_DC", 20000) WEnd Func Check_DC() Local $MIN15 If GetMapLoading() == 2 Or GetAgentExists(-2) == False Then DISCONNECTED() $MIN15 = $MIN + 15 If $MIN15 <= @MIN Then Exit EndIf EndFunc ;==>CHECK_DC Func DISCONNECTED() Local $LCHECK = False Local $LDEADLOCK = TimerInit() Do Sleep(20) $LCHECK = GETMAPLOADING() <> 2 And GETAGENTEXISTS(-2) Until $LCHECK Or TimerDiff($LDEADLOCK) > 5000 If $LCHECK = False Then OUT("Disconnected!") OUT("Attempting to reconnect.") ControlSend(GETWINDOWHANDLE(), "", "", "{Enter}") $LDEADLOCK = TimerInit() Do Sleep(20) $LCHECK = GETMAPLOADING() <> 2 And GETAGENTEXISTS(-2) Until $LCHECK Or TimerDiff($LDEADLOCK) > 60000 If $LCHECK = False Then OUT("Failed to Reconnect 1!") OUT("Retrying.") ControlSend(GETWINDOWHANDLE(), "", "", "{Enter}") $LDEADLOCK = TimerInit() Do Sleep(20) $LCHECK = GETMAPLOADING() <> 2 And GETAGENTEXISTS(-2) Until $LCHECK Or TimerDiff($LDEADLOCK) > 60000 If $LCHECK = False Then OUT("Failed to Reconnect 2!") OUT("Retrying.") ControlSend(GETWINDOWHANDLE(), "", "", "{Enter}") $LDEADLOCK = TimerInit() Do Sleep(20) $LCHECK = GETMAPLOADING() <> 2 And GETAGENTEXISTS(-2) Until $LCHECK Or TimerDiff($LDEADLOCK) > 60000 If $LCHECK = False Then OUT("Could not reconnect!") OUT("Exiting.") ENABLERENDERING() Exit 1 EndIf EndIf EndIf EndIf OUT("Reconnected!") Sleep(5000) EndFunc ;==>DISCONNECTED Hello! I hope this is in the right section, i have read the forum guidelines but they are never clear to me. I am trying to create a function "Check_DC" that checks every 20 seconds (AdlibRegister("Check_DC", 20000), if the script is in a particular loading state (getmaploading) or an figure exists (GetAgentExists) and if so, it then will first call Disconnected() and after 15 min nothing changed then i want it to exit the script. What happens now it continues to spam exit the program before the 15 min check. Link to comment Share on other sites More sharing options...
rudi Posted November 22, 2019 Share Posted November 22, 2019 Hello. @Min is an Autoit Macro returning the "minute-part-of-the-current-time". I think what you are looking for is to "wait some 15 minutes" Have a look at TimerInit() and TimerDiff() CU, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Nine Posted November 22, 2019 Share Posted November 22, 2019 Also having AdlibRegister into a loop seems highly suspicious, but cannot be totally sure since we don't have the full script. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Nachico Posted November 22, 2019 Author Share Posted November 22, 2019 12 minutes ago, Nine said: Also having AdlibRegister into a loop seems highly suspicious, but cannot be totally sure since we don't have the full script. Yeah, i realized that after posting too. There are many loops in the script. It jumps from loop to loop. The while loop is just for example it checks every 20 sec. Posting the original loop would only be confusing since all functions communicate with an API. But my question, is there something wrong with the code itself? Or should this work in theory and i just have to find out the right "position" for it in the script? Link to comment Share on other sites More sharing options...
Nine Posted November 22, 2019 Share Posted November 22, 2019 Like rudi said, using @min like you do is certainly not what you want to achieve. Since you didn't make a runable script, it is hard for us to give you the exact solution. Normally you should provide a snippet that we can run so we can test the script and give you alternative suggestions. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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