Question

I've developed a rather simple OSK for our kiosk application. It works by opening on the onfocus events fired by textboxes in our .net app. The problem is, we're trying to integrate with a single sign-on service which means we'll be opening a webbrowser control to handle the third party authentication. Since the textboxes for the SSO page are inside the browser control, I'm not entirely sure the best way to use the existing OSK, or if I even can.

My initial thoughts are to try some sort of javascript injection in order to add events that my application can respond to. Then I should be able to tell when a textbox receives focus, and open the OSK. Once the OSK is closed, I can update form field with the value that was typed. My problem with this is it seems to be quite fragile. A change in html/js on the SSO page could mess up the sign-in process for all kiosks.

The other option I see is to scrap the OSK I have and use a lower level one. The problem I see with this approach is the poor programability of the OSK software I seem to be finding. I would essentially need to launch a 3rd party exe whenever I needed to get keyboard input from the user and it wouldn't seem like as smooth of an integration as I could get with the existing solution.

I could go with a mix of the two, using our OSK for normal winforms controls and switch to the 3rd party OSK whenever I need to use the webcontrol, but I think everyone could see the problem with that approach.

Any advice/suggestions on which way to go, and any help on implementing a generic javascript injection to allow me to use my existing OSK would be great!

Was it helpful?

Solution

private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.ObjectForScripting = this;
    webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(LoadComplete);
    webBrowser1.Navigate("http://www.google.com");
}

public void LoadComplete(object sender, WebBrowserDocumentCompletedEventArgs args)
{
    foreach(HtmlElement input in webBrowser1.Document.GetElementsByTagName("input"))
    {
        if (input.GetAttribute("type").ToLower() == "text")
        {
            input.Click += new HtmlElementEventHandler(Clicked);
        }
    }
}

public void Clicked(object sender, HtmlElementEventArgs args)
{
    // Show OSK, Get Results Text
        (sender as HtmlElement).SetAttribute("value", oskText);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top