BatMan22 Posted May 26, 2019 Share Posted May 26, 2019 When I run my program below for some reason when the ClickDepartmentButton is called, it causes COM errors and the program to freeze and basically fails... But when I run the ClickDepartmentButton function by itself without running the rest of the code, it works perfectly everytime. Is there something I am doing wrong? Or do I need to perhaps 'reset' the UIA engine or something? I have no clue why it doesn't work when I run it as part of the whole program, but on it's own, it works fine. I even tried to insert a 10second pause to make sure the program was REALLY fully loaded, and it still failed. expandcollapse popupLocal $omega1 = _UIA_getFirstObjectOfElement($UIA_oDesktop, $program, $treescope_children) Local $SDLI = _UIA_getFirstObjectOfElement($omega1, "Analytical", $treescope_subtree) _UIA_action($SDLI, "click") Local $omega2 = _UIA_getFirstObjectOfElement($UIA_oDesktop, $program, $treescope_children) Local $SDLI = _UIA_getFirstObjectOfElement($omega2, "Sample Due", $treescope_subtree) Dim $t $t = StringSplit(_UIA_getPropertyValue($SDLI, $UIA_BoundingRectanglePropertyId), ";") MouseMove($t[1] + ($t[3] / 20), $t[2] + $t[4] / 2) $hTimerDebug = TimerInit() ; Begin the timer and store the handle in a variable. MouseClick("left") AutoItSetOption("MouseCoordMode", 0) WinWait(" - [frmMC_SampleDue]") ClickRefreshButton() ;Click the refresh button - This will cause the program (msaccess) to poll server for data - the program will freeze, this is normal behavior for that software so WaitForHungAndUnhung WinWaitForProgramToStartResondingAgain() WinActivate(" - [frmMC_SampleDue]") ; No effect - Click Department Button still causes freezing/COM errors. ClickDepartmentButton() Func ClickRefreshButton() _UIA_setVar("oP1", "Title:= - [frmMC_SampleDue];controltype:=UIA_WindowControlTypeId;class:=OMain") ;McCampbell Omega_Me - [frmMC_SampleDue] _UIA_setVar("oP2", "Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient") ;Workspace _UIA_setVar("oP3", "Title:=frmMC_SampleDue;controltype:=UIA_WindowControlTypeId;class:=OForm") ;frmMC_SampleDue _UIA_setVar("oUIElement", "Title:=Get Data;controltype:=UIA_ButtonControlTypeId;class:=") ;ControlType:=UIA_ButtonControlTypeId;classname:=") _UIA_Action("oP1", "setfocus") _UIA_Action("oP2", "setfocus") _UIA_Action("oP3", "setfocus") _UIA_action("oUIElement", "click") EndFunc ;==>ClickRefreshButton Func WinWaitForProgramToStartResondingAgain() ;Move a window around, and track how long it takes for it to actually move. $c = 0 Do $hTimerDebug = TimerInit() Local $aPos = WinGetPos(" - [frmMC_SampleDue]") WinMove(" - [frmMC_SampleDue]", "", $aPos[0] + 10, $aPos[1] + 10, $aPos[2] - 20, $aPos[3] - 20) WinMove(" - [frmMC_SampleDue]", "", $aPos[0], $aPos[1], $aPos[2], $aPos[3]) Local $r = WinGetState(" - [frmMC_SampleDue]") Local $fDiff = TimerDiff($hTimerDebug) If $fDiff < 1000 Then $c = 1 ConsoleWrite("Time it took for winmove was: " & $fDiff & @CRLF) Until $c = 1 EndFunc ;==>WinWaitForHungAndUnhung Func ClickDepartmentButton() _UIA_setVar("oP1", "Title:= - [frmMC_SampleDue];controltype:=UIA_WindowControlTypeId;class:=OMain") ; - [frmMC_SampleDue] _UIA_setVar("oP2", "Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient") ;Workspace _UIA_setVar("oP3", "Title:=frmMC_SampleDue;controltype:=UIA_WindowControlTypeId;class:=OForm") ;frmMC_SampleDue _UIA_setVar("oUIElement", "Title:=Dept:;controltype:=UIA_TextControlTypeId;class:=") ;ControlType:=UIA_TextControlTypeId;classname:=") _UIA_Action("oP1", "setfocus") _UIA_Action("oP2", "setfocus") _UIA_Action("oP3", "setfocus") _UIA_action("oUIElement", "click") EndFunc ;==>ClickDepartmentButton ERROR from my ComErrorHandler: SampleDueLoaderv2.1.au3 (1128) : ==> Global COM error handler - COM Error intercepted ! err.number is: 0x00000003 err.windescription: NULL Pointer assignment err.description is: err.source is: err.helpfile is: err.helpcontext is: err.lastdllerror is: 0 err.scriptline is: 1128 err.retcode is: 0x00000000 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