Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all articles
Browse latest Browse all 585

How do I get the visual/window of an automation element?

$
0
0

        

I have an use case as follows,

        Process proc = Process.Start("myproc.exe");
        AutomationElement automationElement = AutomationElement.RootElement.FindFirst(TreeScope.Children,
                    new System.Windows.Automation.PropertyCondition(AutomationElement.ProcessIdProperty,
                        proc.Id));
        var imageAutomationElmt = automationElement .FindFirst
                (TreeScope.Descendants, new System.Windows.Automation.PropertyCondition
                    (AutomationElement.AutomationIdProperty, "imageData"));

        HwndSource src = HwndSource.FromHwnd(Process.GetProcessesByName("myproc")[0].MainWindowHandle);

       

I was planning to acquire the Hwnd and then Visual and render it. But HwndSource is null. I understood all WPF controls need not necessarily have a HWND. All I need is to save the control's data to a file. I am aware of screen capture, but that doesnt suit my use case, I need the actual data within my image control.  How do I render my automation element to a file?




Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>