Access a Silverlight window in Chrome through System.Windows.Automation

This is probably useless, but I wonder if anyone has the opportunity to do this.

I am trying to access a Silverlight application hosted on Google Chrome using System.Windows.Automation (e.g. AutomationElement).

The problem I am facing is that Chrome is hosting the Silverlight application in the child process. If I try to find the "Silverlight Control" AutomationElement (using the main "hWnd" process), it does not work.

If I define a Silverlight host child process, it does not have a window handle, and if I try to find the control using the "Handle it failed" child process.

I know it there ... I see it using Inspect

Jerkface

but I can find this by clicking in the Silverlight application and going to Inspect. I cannot navigate from the tab window using AutomationElement.FindFirst or Inspect.

This is similar to the gap between the window and the Silverlight plugin that is not observed in IE or Firefox, and I don't know how to get around it.

Can anyone else do this?

+4
source share
1 answer

I'm not sure if this helps or not in your instance, but I came across several instances where I needed to enable communication in Silverlight from the outside (Office Application AddIns, which should interact with Silverlight Application). I used javascript on the html page that hosts the Silverlight application as a bridge for 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 is additional information that I can provide, let me know. I hope this will be useful to you.

+1
source

Source: https://habr.com/ru/post/1344986/


All Articles