boxstart Posted December 20, 2013 Posted December 20, 2013 I've an AutoIt script that uses a COM-object (created with VB6). The COM-object can fire events. I would like to use these events to display progress of a task in the AutoIt script, because the execution of the VB6 task can take up to 10 minutes. The problem is that the events are being fired, but that they are handled in AutoIt after the processing of the 'huge' task has ended. Below you can find a reduced version of the script. In the real-life version of the script a GUI is used and the progress percentage should not be written to the console, but to the inner text of a 'DIV' element. expandcollapse popupWork() Func Work() Local $g_oReport = ObjCreate("wcDashboardTools.DashBoardToolsVB6") If IsObj($g_oReport) Then $g_oReport.Server = "my-sql-server-name" Local $g_oReportEvents = ObjEvent($g_oReport,"ToolsEvent_") ; Start receiving Events. ; test the events three times (the 'InitEvents' methods only raises the event in VB6) $g_oReport.InitEvents() Sleep(3000) $g_oReport.InitEvents() Sleep(3000) $g_oReport.InitEvents() ; in the test application this works and the event messages now have been written to the console ; in the real life application, these 'test' messages will only be written to the console after the report results have been rendered $g_oReport.Database = "my-database-name" $g_oReport.FinancialYear = 2013 $g_oReport.FinancialPeriodStart = 1 $g_oReport.FinancialPeriodEnd = 1 $g_oReport.ReportLayout = "my-layout-name" ; start the huge task $g_oReport.CreateReport() ; at this point, the huge task has been completed ConsoleWrite("Creation of the report finished, start rendering the report") If @Compiled = 0 Then $g_oReport.StoreReportAsXml("c:\temp\exploreport.xml") ; start rendering $sHTML = $g_oReport.GetReportAsHtmlString() ConsoleWrite($sHTML) Else ConsoleWrite("FOUT: Het genereren van de rapportage is mislukt.") EndIf EndFunc Func ToolsEvent_OnTaskProgressChange($taskProgress) ConsoleWrite('Progress(%): ' & $taskProgress & @CRLF) EndFunc The 'CreateReport' method of the COM-object fires the event two times before actually starting the 'huge' task itself. However, the messages for these events only will be written to the console after the rendered HTML is written to the console. Can anybody help me to make sure that the events are handled within the AutoIt script at the correct moment (during execution of the 'huge' task)? Thanks in advance! Björn P.S. I made a reference implementation in C# which uses the same VB6 (Interop) and then the events are handled at the correct moment.
MilesAhead Posted December 20, 2013 Posted December 20, 2013 (edited) I had a similar experience. I wrote an ActiveXControl in Delphi 5 to do Message Boxes with stylized background colors. You could add a Help Button to the message box. It used the help event to call a function with an integer param(the help context.) It worked in C#, C++, VB, but, as in your case, the help dialog from pressing the Help Button was only shown after the user closed the message dialog, in AutoIt3. For this reason I don't think the likelihood of a fix is high. It's just how AutoIt3 is put together. Edited December 20, 2013 by MilesAhead My Freeware Page
Solution trancexx Posted December 21, 2013 Solution Posted December 21, 2013 Try making event function synchronous. You can search beta help file for "volatile" function modifier keyword. ♡♡♡ . eMyvnE
boxstart Posted December 21, 2013 Author Posted December 21, 2013 Thanks Trancexx! I tried the 'volatile' keyword with Beta versio 3.3.9.25 and now the timing of the event handling is how it should be. Unfortunately, we use AutoIt for a business critical application, so using a beta version is not on my wish list. I will try to find another solution (display progress from within the COM-classes or something like that), but I appreciate your answer very much!
Moderators Melba23 Posted December 21, 2013 Moderators Posted December 21, 2013 boxstart,Look back here in a few days time - you might find that your "Beta aversion" is no longer a problem. Although that particular section of the code is unlikely to have been changed from what is currently available. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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