Access Silverlight window within Chrome via System.Windows.Automation
This is probably futile, but I'm wondering if anyone out there has experience doing this.
I'm trying to access a Silverlight application hosted within Google Chrome by using Syst开发者_如何学Pythonem.Windows.Automation (e.g., AutomationElement).
The problem I'm having is that Chrome hosts the Silverlight app within a child process. If I attempt to find the "Silverlight Control" AutomationElement (by using the main process' hWnd), it fails.
If I locate the Silverlight host child process, it does not have a window handle, and if I attempt to find the control using the child process' Handle it fails.
I know it's there... I can see it using Inspect
but I can only find this by clicking in the Silverlight app and navigating up in Inspect. I cannot navigate down from the tab window using AutomationElement.FindFirst or Inspect.
Its like there is a disconnect between the window and the Silverlight plugin that isn't seen in IE or Firefox, and I don't know how to get around it.
Has anybody else been able to do this?
I'm not sure if this helps or not in your instance but I've run into a couple instances where I needed to enable communication into Silverlight from outside (Office Application AddIns that need to communicate with the Silverlight Application). I've used javascript in the html page hosting the Silverlight Application as a bridge for that communication:
function sendToNav(message) {
var nav = document.getElementById("Nav");
nav.content.NavigationPage.HandleScriptedMessage(message);
}
function passMessageToHost(message) {
if (window.external == null) return;
window.external.HandleScriptedMessage(message);
}
If there any additional information I can provide please let me know. Hope this is of some use to you.
精彩评论