user1227708
user1227708

Reputation: 241

UI Automation, How to getting the underlying GUI Object?

I am using the UI Automation(COM wrapper) framework for most of my testing but I have come to a control that I cannot see inner controls on and I do not want to do Click(60, 100) at all.

I wanted to know if there is a simple way to get the object its self,

I want to use something like Control.FromHandle() but since my app is not in the same PID as the test this returns null.

I think I might have to use injection but I dont know if I can pass the GUI object back to my main thread (from the injected one)

I believe the control is a ListBar (from infragistics) if that helps.

Any advice would be appreciated

Upvotes: 1

Views: 704

Answers (1)

Andreas Reiff
Andreas Reiff

Reputation: 8404

Like Brendan said, you can get then handle (HWND/IntPtr) and then use all the goodness of the Win32SDK with that handle.

I had a few scenarios myself, where e. g. certain toolbars do not expose their children through UIAutomation, but with (complicated) SDK calls, you could still get them.

Mind you, the easiest - and also pretty (though not 100%ly reliable) solution is to use screen coordinates relative to the parent control. Typically, the children do not change their position, so everything runs fine 99.99% of times.

Slightly less reliable, a lot a lot faster (a bit in runtime, a lot in development time).

Upvotes: 1

Related Questions