Home > Software engineering >  UI Automation Error
UI Automation Error

Time:09-16

Recently in the use of the UI automationcore. DLL in VBA to make some simple automation,
Find the listview/treeview/saveas dialog controls such as window, click on the button above,
Met two questions, call the UI automation in vba feels as though it is not very stable,


A code.
The Set oSearchUIElement=oUIElement. FindFirst (vTreeScope oFinalCondition),
Sometimes it doesn't directly effect, oSearchUIElement remained nothing, without judging running down, can appear automation error and other errors.
Is there a better way to avoid this kind of situation?

While oSearchUIElement Is Nothing
The Set oSearchUIElement=oUIElement. FindFirst (vTreeScope oFinalCondition)
If oSearchUIElement Is Nothing Then
Sleep (100)
End the If
Wend


Just a little code,
Click on the button method is used to invoke, sometimes by simulation of the system will be in a state of no response, then the following this sentence InvokePat invoke is stuck, not run down, each time after about 2-3 seconds later, the code to continue, sometimes waiting for a response time will be longer, and often after invoke complains, before I can invoke plus on the error resume next to continue,

Obj. SetFocus
The Set InvokePat=oElement2ActOn. GetCurrentPattern (UIA_InvokePatternId)
InvokePat. Invoke




  •  Tags:  
  • API
  • Related