BigDaddyO Posted January 24, 2017 Share Posted January 24, 2017 I have a script I put together for some end users to retrieve records from a database to use for their tests. There are about 12 queries I run to ensure I get Valid records but 3 of them are rather long running, about 5 minutes each. so when it gets to these queries after a few minutes the GUI freezes and shows (Not Responding). It always recovers but the (Not Responding) is rather alarming for the end users and it also seems to halt the fancy Animated GIF I have which was supposed to show the query was still running. Is there something I can maybe add to AdlibRegister to fool windows into thinking it's still working? Thanks for any ideas you might be able to offer. Mike Link to comment Share on other sites More sharing options...
Developers Jos Posted January 24, 2017 Developers Share Posted January 24, 2017 What statement is it hanging on during the execution of the query? 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...
BigDaddyO Posted January 24, 2017 Author Share Posted January 24, 2017 It hangs right after $RS.Open($sSQL, $Conn) while the query is running. Once data starts coming in, the UI recovers and moves on to the next one. Here is one of the long running functions. I chopped the Query part out. expandcollapse popupFunc _Query_UserIDs($Conn, $iRecords) $sSQL = 'Select DISTINCT Top ' & $iRecords & ' Big Query that works but takes a while' $RS = ObjCreate("ADODB.Recordset") ;Create a new recordset to hold this modules RefID's $RS.CursorType = 3 ;Type of connection 3 = get data at time of query, all changes from others while connected will be ignored. $RS.Open($sSQL,$Conn) ;Perform the SQL Query on the connected Database ;Start working through the records returned if $RS.EOF then Return SetError(1, 1, 0) ;Error, no records were returned. else $RS.MoveFirst $iRecordCount = $RS.RecordCount With $RS If .RecordCount Then While Not .EOF $sOutputValue &= @CRLF & "ModuleName|" & StringStripWS(.Fields("RefID").Value, 3) .movenext WEnd EndIf EndWith Endif $RS.close Return $iRecordCount EndFunc ;_Query_UserIDs Link to comment Share on other sites More sharing options...
Developers Jos Posted January 24, 2017 Developers Share Posted January 24, 2017 Ok, so you created your own SQL request with a com object. The only "easy" solution I can think of is to re-shell your own script to perform the sql statement and in the mean time monitor the newly shelled script instance in the main script. Look at AutoI3Wrapper that does something similar for a different purpose. 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...
BigDaddyO Posted January 24, 2017 Author Share Posted January 24, 2017 I was afraid you were going to say something like that. I'll take a look at the Wrapper to see about doing something similar. Thank you very much. Mike Link to comment Share on other sites More sharing options...
Developers Jos Posted January 24, 2017 Developers Share Posted January 24, 2017 It isn't that hard really. 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...
meeoun Posted August 23, 2021 Share Posted August 23, 2021 I wanted to add a response. I realize that this topic has not seen a response in a while. You can get AutoIT to not lock the GUI process by using the AdLibRegister and the AdLibUnRegister functions. It requires a bit of creativity in your organization, but not too much. i.e. place the logic in a function and keep your global's status in mind as it executes. Func ProcessWebSiteTests() ;add function to library AdlibRegister ("TestWebsites") EndFunc Func TestWebsites() Global $sDesiredCapabilities $sDesiredCapabilities = SetupEdge() GUICtrlSetState($testWebButton, $GUI_DISABLE) TestWebsiteAvailability($fergusonImage, $fergusonProgress, "https://www.test.com") TestWebsiteAvailability($buildImage, $buildProgress, "https://btest.com") TestWebsiteAvailability($supplyImage, $supplyProgress, "https://test.com") TestWebsiteAvailability($pipeImage, $pipeProgress, "https://mydigitalspace.sharepoint.com/sites/mypipeline") TestWebsiteAvailability($workImage, $workProgress, "https://www.test.com/test/d/home.htmld") TestWebsiteAvailability($powerImage, $powerProgress, "https://app.powerbi.com/home") TestWebsiteAvailability($vcollectImage, $vcollectProgress, "http://test:9090/VoiceConsole/login.action?error=true") TestBlockedWebsite($blockedImage, $blockedProgress, "https://dosgames.com") GUICtrlSetState($testWebButton, $GUI_ENABLE) _WD_Shutdown() ;unregister to prevent continuous execution AdlibUnRegister("TestWebsites") EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted August 24, 2021 Developers Share Posted August 24, 2021 (edited) 7 hours ago, meeoun said: ou can get AutoIT to not lock the GUI process by using the AdLibRegister and the AdLibUnRegister functions. This is only true when the active function is none-blocking! Edited August 24, 2021 by 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...
meeoun Posted August 26, 2021 Share Posted August 26, 2021 Yeah, I made an assumption when I was able to use the adlibregister method to interrupt a process and remove the not responding message. However, the help text for adlibregister indicates that the main code is blocked while executing, so that is a bit confusing to read. In my case, I was able to use it to stop the GUI from indicating not responding and to also interrupt the function and make it exit. In other languages, you usually multithread so that the gui thread does not tie up. I understand that AutoIT never intends to introduce multi-threading, which is fine, perhaps helper functions that abstract it in specific ways? It might be nice if AutoIT provided a method that worked like adLibRegister, but just ran the function on its own thread. Would be pretty easy to use and not tie up the gui thread that autoit must be running. Link to comment Share on other sites More sharing options...
mLipok Posted August 26, 2021 Share Posted August 26, 2021 (edited) btw. @BigDaddyO did you solve your problem with ADO ? In your case it is related to the fact that you are opening RS in sync mode. $RS.Open($sSQL,$Conn) ;Perform the SQL Query on the connected Database This mean ADO "steal focus from AutoIt" on entire SQL statement procesing and delivering data to object. As you said: $sSQL = 'Select DISTINCT Top ' & $iRecords & ' Big Query that works but takes a while' This query processing "takes a while", and for this time period, AutoIt processing capabilities is stolen by ADO internal processing. I think that you should open recordset in asynchronic way with adAsyncFetchNonBlocking Take a look here:https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/open-method-ado-recordset?view=sql-server-ver15 Then you will be able to watch on Events :https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/fetchprogress-event-ado?view=sql-server-ver15https://docs.microsoft.com/en-us/sql/ado/reference/ado-api/fetchcomplete-event-ado?view=sql-server-ver15 I mean focus should back to AutoIt processing just after you use: $RS.Open(.....) and after FetchComplete event will be fired (which you must check in a loop) then you can start analyze data row by row. If you are still interested in solving this problem, I will gladly try to help you solve this problem using my ADO.au3 UDF. Edited August 26, 2021 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...
BigDaddyO Posted August 27, 2021 Author Share Posted August 27, 2021 I don't even remember posting this question, so I'm assuming I figured it out. Earthshine 1 Link to comment Share on other sites More sharing options...
Earthshine Posted August 27, 2021 Share Posted August 27, 2021 nice. so give yourself a point by solving it.. My resources are limited. You must ask the right questions 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