mLipok Posted October 31, 2018 Share Posted October 31, 2018 (edited) Today I start to have problem with one of mine program. He start to be unresposive. Here is an example script which will show you how it happend and how I solve this problem. expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $__g_bTryToAvoidUnresponsiveGUI = ($IDYES == MsgBox($MB_YESNO, 'Choose:', 'Should I try to avoid unresponsive GUI ?')) Global $__g_iMinimalWaitTime = 1 Global $__g_idLabel _Example() AdlibUnRegister(_AdlibRegister_Wrapper) Exit Func _Example() AdlibRegister(_AdlibRegister_Wrapper) ; Create a GUI with various controls. Local $hGUI = GUICreate("Example",400,100) $__g_idLabel = GUICtrlCreateLabel('Wait', 10,10, 380, 80) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $idMsg = 0 ; Loop until the user exits. Local $iStep = 0 While Sleep(100) $iStep += 1 ; Try to focus what is going on with this following line when $__g_bTryToAvoidUnresponsiveGUI = False ConsoleWrite("- $iStep =" & $iStep & @CRLF) ; in case $__g_bTryToAvoidUnresponsiveGUI = False ...... did you saw "- $iStep =10" in console ? If $__g_iMinimalWaitTime < 1000 Then ContinueLoop ; if $__g_bTryToAvoidUnresponsiveGUI = False then the following line after few WhileWend Loop, should never be fired properly anymore $idMsg = GUIGetMsg() ConsoleWrite("- $idMsg = " & $idMsg & @CRLF) Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>_Example Func _AdlibRegister_Wrapper() Local Static $iCurrentCallInterval = 250 #Region - calling Inner functions and measuring Time Local $hTimer = TimerInit() _AdlibExample_1() _AdlibExample_2() _AdlibExample_3() Local $fDiff = TimerDiff($hTimer) #EndRegion - calling Inner functions and measuring Time $__g_iMinimalWaitTime = $fDiff ConsoleWrite("+ _AdlibRegister_Wrapper: time " & Round($fDiff) & @CRLF) GUICtrlSetData($__g_idLabel, _ "_AdlibRegister_Wrapper: time " & Round($fDiff) & @CRLF & _ @CRLF & _ "Wait until will be > 1000 and then try to close GUI." _ ) #Region TESTING If $__g_bTryToAvoidUnresponsiveGUI And $fDiff > $iCurrentCallInterval Then $iCurrentCallInterval = Round($fDiff) + 100 ConsoleWrite("! NEW INTERVAL=" & $iCurrentCallInterval & @CRLF) AdlibUnRegister(_AdlibRegister_Wrapper) AdlibRegister(_AdlibRegister_Wrapper, $iCurrentCallInterval) EndIf #EndRegion TESTING EndFunc ;==>_AdlibRegister_Wrapper Func _AdlibExample_1() ; sleep 10 ms longer per each start Local Static $iSleep = 1 Local $hTimer = TimerInit() Sleep($iSleep) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example1: time " & Round($fDiff) & @CRLF) $iSleep += 10 EndFunc ;==>_AdlibExample_1 Func _AdlibExample_2() ; sleep 15 ms longer per each start Local Static $iSleep = 1 Local $hTimer = TimerInit() Sleep($iSleep) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example2: time " & Round($fDiff) & @CRLF) $iSleep += 15 EndFunc ;==>_AdlibExample_2 Func _AdlibExample_3() ; sleep 20 ms longer per each start Local Static $iSleep = 1 Local $hTimer = TimerInit() Sleep($iSleep) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example3: time " & Round($fDiff) & @CRLF) $iSleep += 20 EndFunc ;==>_AdlibExample_3 Regards, mLIpok Edited October 31, 2018 by mLipok Skeletor 1 Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Skeletor Posted November 1, 2018 Share Posted November 1, 2018 I couldn't close the GUI... both were unresponsive. Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI Link to comment Share on other sites More sharing options...
mLipok Posted November 1, 2018 Author Share Posted November 1, 2018 What you have in console when you choose YES . Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
mLipok Posted November 16, 2018 Author Share Posted November 16, 2018 On 1.11.2018 at 11:40 AM, Skeletor said: I couldn't close the GUI... both were unresponsive. Could you answer to my last question ? Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
water Posted November 16, 2018 Share Posted November 16, 2018 I think the help file explains what goes on: Quote The adlib function should be kept simple as it is executed often and during this time the main script is paused. BTW: I think the AutoIt Example Scripts forum is the wrong place for this thread. Should be GH&S forum, right? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
mLipok Posted November 16, 2018 Author Share Posted November 16, 2018 (edited) I know about this HelpFile statement. The problem is that Adlib does not have any protection against this problem. User does not have control over all cases, and somtimes the called function will be proceeded longer then time declared in AdlibRegister() function. If the previous call was not completed, the next call should not be made. Unfortunately, this look like AutoIt using Adlib puts every call into the stack, and proceed them immediately one by one, and If the stack already contains, for example, dozens of delayed calls, then the program does not respond. My snippet is showing what could happend (just happend to me recently) and how it could be fixed. So IMHO this is not for GH&S forum, and the ExampleScript forum is a good place. Edited November 16, 2018 by mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2018 Developers Share Posted November 16, 2018 Trying to understand how this is different/better than simply using the GUIEvent Mode? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
water Posted November 16, 2018 Share Posted November 16, 2018 IMHO the forum description states why this thread should be moved to the GH&S forum: Quote Share your cool AutoIt scripts, UDFs and applications with others. Do not post general support questions here, instead use the AutoIt Help and Support forums. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
dmob Posted November 16, 2018 Share Posted November 16, 2018 5 hours ago, mLipok said: User does not have control over all cases, and somtimes the called function will be proceeded longer then time declared in AdlibRegister() function. How about disabling Adlib when you enter the function the re-enable Adlib upon/after leaving function? Link to comment Share on other sites More sharing options...
mLipok Posted November 16, 2018 Author Share Posted November 16, 2018 (edited) @dmob the problem is that I'm doing exactly what you are saying, but the processing of this function can take even few hour, it depends on how much data user input at the begining. Edited November 16, 2018 by mLipok wording Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
argumentum Posted November 17, 2018 Share Posted November 17, 2018 (edited) 15 hours ago, mLipok said: but the processing of this function can take even few hour AdlibRegister("thisFunc", 250) Func thisFunc() AdlibUnRegister("thisFunc") Sleep(6000) ; so longer than expected AND nothing else will run while running this function AdlibRegister("thisFunc", 250) EndFunc I don't understand the topic much. By now you know a lot. A process that takes that long AND a gui ... I'd fork the process and wait for the processClose or IPC. Adlib does not make AutoIt multi-threading ( ups, I've said a bad word ). PS: ..think you'd like a "AdlibRegister ( "function" [, time = 250] ,[ timeout = -1 ])" but that is a feature request that would create more problems than it would solve. Edited November 17, 2018 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted November 17, 2018 Share Posted November 17, 2018 (edited) 4 hours ago, argumentum said: PS: ..think you'd like a "AdlibRegister ( "function" [, time = 250] ,[ timeout = -1 ])" OK !!!, got it. AdlibEnable() works as expected. AdlibRegister() does not !. But I'm the only few ( or one ), who would try every version or AutoIt digging to when did it ever work. So it's a booboo , ...this is above any of us. Is upto the creator to look at it again. Sowy for my post above, I did not try your code before posting. Code for AutoIt v3.2.12.1 (removed, look at the next post). Edited November 17, 2018 by argumentum removed the code Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted November 17, 2018 Share Posted November 17, 2018 (edited) ok, I drilled down to AdlibUnRegister not acting timely. The code below should run on v3.2.12.x and the v3.3.x.x ( where AdlibUnRegister replaced AdlibDisable ). expandcollapse popup; AutoIt v3.2.12.1 and v3.3.14.x ; ; all versions of AutoIt should have the same behaviour ; but "AdlibUnRegister" seem to fail to act timely ( and/or in sync ). ; in the versions where "AdlibUnRegister": ; in about round < 5 the GUI is responsive, above that, it isn't, until round > 9 ( purposely turn OFF for a last time ) ConsoleWrite("@AutoItVersion = " & @AutoItVersion & @CRLF) Global Const $AutoItVersionOld = String(@AutoItVersion) = "3.2.12.1" Global Const $IDYES = 6, $MB_YESNO = 4, $GUI_EVENT_CLOSE = -3 Global $__g_idLabel, $__g_id2Label Global $__g_iSleep1 = 1 Global $__g_iSleep2 = 1 Global $__g_iSleep3 = 1 Global $iCurrentCallInterval = 1000 ; <----- argumentum: changed to better show the flaw. Global $__g_iCountOnOffs = 0 ; ROUNDs counter _Example() Adlib_OFF() Exit Func Adlib_ON() $__g_iCountOnOffs += 1 If $__g_iCountOnOffs >= 10 Then Return GUICtrlSetData($__g_id2Label, "AdLib SHOULD NOT run anymore ( ROUND: " & $__g_iCountOnOffs & " )") If $AutoItVersionOld Then Execute('AdlibEnable("_AdlibRegister_Wrapper", $iCurrentCallInterval)') Else Execute('AdlibRegister("_AdlibRegister_Wrapper", $iCurrentCallInterval)') EndIf GUICtrlSetData($__g_id2Label, "AdLib IS running, but GUIGetMsg() is queued. ( ROUND: " & $__g_iCountOnOffs & " )") EndFunc ;==>Adlib_ON Func Adlib_OFF() If $AutoItVersionOld Then Execute('AdlibDisable()') Else Execute('AdlibUnRegister("_AdlibRegister_Wrapper")') EndIf GUICtrlSetData($__g_id2Label, "AdLib IS NOT running ( ROUND: " & $__g_iCountOnOffs & " ) GUIGetMsg() is queued") EndFunc ;==>Adlib_OFF Func _Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 400, 100) $__g_idLabel = GUICtrlCreateLabel('Wait', 10, 10, 380, 80) $__g_id2Label = GUICtrlCreateLabel('AdLib ?', 10, 70, 380, 80) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) WinSetOnTop($hGUI, "", 1) Adlib_ON() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>_Example Func _AdlibRegister_Wrapper() Adlib_OFF() #Region - calling Inner functions and measuring Time Local $hTimer = TimerInit() _AdlibExample_1() _AdlibExample_2() _AdlibExample_3() Local $fDiff = TimerDiff($hTimer) #EndRegion - calling Inner functions and measuring Time ConsoleWrite("+ _AdlibRegister_Wrapper: time " & Round($fDiff) & @CRLF) GUICtrlSetData($__g_idLabel, _ "_AdlibRegister_Wrapper: time " & Round($fDiff) & @CRLF & _ @CRLF & _ "Wait until will be > 1000 and then try to close GUI." _ ) Adlib_ON() EndFunc ;==>_AdlibRegister_Wrapper Func _AdlibExample_1() ; sleep 10 ms longer per each start Local $hTimer = TimerInit() Sleep($__g_iSleep1) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example1: time " & Round($fDiff) & @CRLF) $__g_iSleep1 += 10 * 10 ; <----- argumentum: speed up the effect EndFunc ;==>_AdlibExample_1 Func _AdlibExample_2() ; sleep 15 ms longer per each start Local $hTimer = TimerInit() Sleep($__g_iSleep2) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example2: time " & Round($fDiff) & @CRLF) $__g_iSleep2 += 15 * 10 ; <----- argumentum: speed up the effect EndFunc ;==>_AdlibExample_2 Func _AdlibExample_3() ; sleep 20 ms longer per each start Local $hTimer = TimerInit() Sleep($__g_iSleep3) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example3: time " & Round($fDiff) & @CRLF) $__g_iSleep3 += 20 * 10 ; <----- argumentum: speed up the effect EndFunc ;==>_AdlibExample_3 Edited November 17, 2018 by argumentum typing Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
argumentum Posted November 17, 2018 Share Posted November 17, 2018 a workaround for now. expandcollapse popup; AutoIt v3.3.x.x Adlib workaround #include <Timers.au3> ; for workaround, is to queue the Adlib function via _Timer_SetTimer() ConsoleWrite("@AutoItVersion = " & @AutoItVersion & @CRLF) Global Const $AutoItVersionOld = String(@AutoItVersion) = "3.2.12.1" Global Const $IDYES = 6, $MB_YESNO = 4, $GUI_EVENT_CLOSE = -3 Global $__g_idLabel, $__g_id2Label, $__g_hGUI, $__g_iIDtimer Global $__g_iSleep1 = 1 Global $__g_iSleep2 = 1 Global $__g_iSleep3 = 1 Global $iCurrentCallInterval = 250 Global $__g_iCountOnOffs = 0 ; ROUNDs counter _Example() Adlib_OFF() Exit #Region workaround Func Adlib_Queue_ON($hWnd, $iMsg, $iIDtimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer,$iTime ConsoleWrite('- Adlib_Queue_ON' & @CRLF) Adlib_ON() EndFunc ;==>Check_mounted #EndRegion workaround Func Adlib_ON() #Region workaround If $__g_iIDtimer Then If _Timer_KillTimer($__g_hGUI, $__g_iIDtimer) Then $__g_iIDtimer = 0 Else $__g_iIDtimer = _Timer_SetTimer($__g_hGUI, 10, "Adlib_Queue_ON") ; create timer Return EndIf #EndRegion workaround $__g_iCountOnOffs += 1 If $__g_iCountOnOffs >= 10 Then GUICtrlSetData($__g_id2Label, "AdLib SHOULD NOT run anymore ( ROUND: " & $__g_iCountOnOffs & " )") If $__g_iIDtimer Then _Timer_KillTimer($__g_hGUI, $__g_iIDtimer) Return EndIf AdlibRegister("_AdlibRegister_Wrapper", $iCurrentCallInterval) GUICtrlSetData($__g_id2Label, "AdLib IS running, but GUIGetMsg() is queued. ( ROUND: " & $__g_iCountOnOffs & " )") EndFunc ;==>Adlib_ON Func Adlib_OFF() AdlibUnRegister("_AdlibRegister_Wrapper") GUICtrlSetData($__g_id2Label, "AdLib IS NOT running ( ROUND: " & $__g_iCountOnOffs & " ) GUIGetMsg() is queued") EndFunc ;==>Adlib_OFF Func _Example() ; Create a GUI with various controls. $__g_hGUI = GUICreate("Example", 400, 100) $__g_idLabel = GUICtrlCreateLabel('Wait', 10, 10, 380, 80) $__g_id2Label = GUICtrlCreateLabel('AdLib ?', 10, 70, 380, 80) ; Display the GUI. GUISetState(@SW_SHOW, $__g_hGUI) WinSetOnTop($__g_hGUI, "", 1) Adlib_ON() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($__g_hGUI) EndFunc ;==>_Example Func _AdlibRegister_Wrapper() Adlib_OFF() #Region - calling Inner functions and measuring Time Local $hTimer = TimerInit() _AdlibExample_1() _AdlibExample_2() _AdlibExample_3() Local $fDiff = TimerDiff($hTimer) #EndRegion - calling Inner functions and measuring Time ConsoleWrite("+ _AdlibRegister_Wrapper: time " & Round($fDiff) & @CRLF) GUICtrlSetData($__g_idLabel, _ "_AdlibRegister_Wrapper: time " & Round($fDiff) & @CRLF & _ @CRLF & _ "Wait until will be > 1000 and then try to close GUI." _ ) Adlib_ON() EndFunc ;==>_AdlibRegister_Wrapper Func _AdlibExample_1() ; sleep 10 ms longer per each start Local $hTimer = TimerInit() Sleep($__g_iSleep1) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example1: time " & Round($fDiff) & @CRLF) $__g_iSleep1 += 10 * 10 ; <----- argumentum: speed up the effect EndFunc ;==>_AdlibExample_1 Func _AdlibExample_2() ; sleep 15 ms longer per each start Local $hTimer = TimerInit() Sleep($__g_iSleep2) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example2: time " & Round($fDiff) & @CRLF) $__g_iSleep2 += 15 * 10 ; <----- argumentum: speed up the effect EndFunc ;==>_AdlibExample_2 Func _AdlibExample_3() ; sleep 20 ms longer per each start Local $hTimer = TimerInit() Sleep($__g_iSleep3) Local $fDiff = TimerDiff($hTimer) ConsoleWrite("> Example3: time " & Round($fDiff) & @CRLF) $__g_iSleep3 += 20 * 10 ; <----- argumentum: speed up the effect EndFunc ;==>_AdlibExample_3 Skeletor 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Skeletor Posted November 18, 2018 Share Posted November 18, 2018 @argumentum, tried this piece of code and yeah it works for me. I can close the gui. + _AdlibRegister_Wrapper: time 2729 - Adlib_Queue_ON > Example1: time 710 > Example2: time 1060 > Example3: time 1410 + _AdlibRegister_Wrapper: time 3180 - Adlib_Queue_ON > Example1: time 810 > Example2: time 1505 > Example3: time 1601 + _AdlibRegister_Wrapper: time 3916 +>03:05:02 AutoIt3.exe ended.rc:0 +>03:05:02 AutoIt3Wrapper Finished. >Exit code: 0 Time: 19.89 argumentum 1 Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI 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