-1

I have an AutomationElement for a particular WPF Button in an external application from the WPF application that I am try to access. Is there a way to find out the button's IsDefault property?

I have tried to access the button's window's control through its handle, using (Window)HwndSource.FromHwnd(hWnd).RootVisual,where hWnd is the button's window's NativeWindowHandle, but FromHwnd returns null.

M_Tee
  • 3
  • 3
  • Is IsDefault an attached property? – Greg D May 19 '15 at 16:45
  • @GregD I don't think so. [IsDefault](https://msdn.microsoft.com/en-us/library/system.windows.controls.button.isdefault%28v=vs.110%29.aspx) seems to be just a regular property. – M_Tee May 19 '15 at 16:51

1 Answers1

0

Normally, you can't access a WPF control object in another process. You might be able to do something with a tool like Snoop. In this particular case, I see that when I set IsDefault to true, the AccessKey property on the button's automation element is "\r". Otherwise it is empty ("").

Mike Zboray
  • 39,828
  • 3
  • 90
  • 122
  • Unfortunately in my case, the AccessKey is set to something different. Would a button where IsDefault is true always have an AccessKey of "\r"? – M_Tee May 19 '15 at 19:24
  • @M_Tee Obviously it can be different if you set `AutomationProperties.AccessKey` to something else. This is just what I saw when testing a toy example. – Mike Zboray May 20 '15 at 01:28