I am working with MS UIAutomation on windows 7 (64bit). I want to know if it is possible to make the UIAutomation element persist, if so what could be the starting point to do it.
The only thing I came up with is RuntimeID of an element, but the problem is that some elements may not have an id.
A simple scenario I want to achieve is that I find out the UIAutomation element of a control on the screen by using the AutomationElement.FromPoint()
, now I want to persist it, so that next time I can easily access it by "Loading" it back to a UIAutomation Element
.
No, you cannot persist the UIAutomation element from the automation client. You will need to store sufficient information about the element (the AutomationID and context are the best, if available) to find it again the next time.
The element is a reference to the object in (probably) some other process, and it can only live so long as that other process lets it. Elements are likely to go away when their windows close, the app closes, etc. Elements such as menus and flyouts are likely to be very short lived, and may no longer exist by the time the client receives a notification.