I'm trying to use UI Automation with C# to type file path in opened Open
dialog and then press Open button. I'm able to find the dialog itself, but searching for inner elements (file path text box and Open button) gives no result. When I traverse elements tree writing elements to log file, I see that the log is obviously too short and not all elements printed out.
Strange behavior: if I switch with mouse on another window, traversing of the dialog returns all elements and I'm able to find desired controls and interact with them.
I've tried many approaches to bypass the problem:
AutomationElement.SetFocus
; FindWindowEx
); AutomationElement
by point on screen within dialog's bounding rectangle iterating by x and y with some step. No one approach give me desired result.
What can cause incomplete elements tree using UI Automation and what is workaround for this?
My scenario is:
I finally came to this workaround:
AutomationElement
by the handle; SendKeys.SendWait
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.