none
Does Touch Injection API work with WPF UIs? RRS feed

  • General discussion

  • Hi, I'm working on writing automaiont test cases for our WPF app using Automation UI in Windows 8.

    And i tried to use touch injection API to simulation touch inputs.

    I tried the following example, it works fine with win32 apps, but with WPF UI, it does not activate the controls.

    When it taps on a button, the button will be highlighed but not activated...

    http://code.msdn.microsoft.com/windowsdesktop/Touch-Injection-Sample-444d9bf7

    So my question is, does Touch Injection API support WPF, if it does, is there anything that need to be configured?


    • Edited by Becky_Liu Thursday, May 23, 2013 9:22 AM
    Thursday, May 23, 2013 9:21 AM

All replies

  • We might have the same issue.

    I am able to use touch injection without trouble anywhere and also on WPF apps.

    But as soon as I change resolution, it will not work. It is the same behaviour as you describe, a button will be activated but not clicked. In my experiments it will only affect the hosting WPF application. I am calling touch injection calls via Interop on a WPF C# application, and after a resolution change, it will not be able to send a "tap" to the window. I am still able to send inputs to any other application.

    Some observations:
    *Calling touch init and inject on a different thread than the main window or a UI thread, does not change any behaviour.
    *Restarting the application gets it to work again.
    *Calling InitializeTouchInjection on the "SystemEvents.DisplaySettingsChanged" event does not solve it.
    *I have not been able to reproduce the problem with anything else than changing resolution.

    EDIT: Using the exact same code on a WPF vs WinForms application confirms that the problem only exists on WPF applications.

    EDIT 2: The "un-tappable" WPF application will be "tappable" again if InitializeTouchInjection is called from another process. The second process does not need to be WPF.

    Any ideas what might cause this "bug"? Is there something we are missing?



    • Edited by simphax Tuesday, May 28, 2013 6:34 PM
    Tuesday, May 28, 2013 5:35 PM
  • Ok, so, a temporary solution would be to start a new process that runs InitializeTouchInjection every time the resolution changes.

    I will link to a compiled exe and its source below, that does nothing more than this. You might want to hook the event called SystemEvents.DisplaySettingsChanged and run the executable with a System.Diagnostics.Process class.

    I would really appreciate if anyone will come up with a better solution. This is just a hack. It may be Microsoft that will need to come up with an bug fix for WPF or .NET though.

    http://ge.tt/9AyMCth/v/0?c

    Tuesday, May 28, 2013 7:25 PM
  • Hi simphax,  thanks for your reply.

    TouchInjection API never worked with my WPF GUI.

    I tried your solution and still got no luck....

    This is frustrating....


    Becky Liu

    Thursday, June 6, 2013 8:45 AM
  • For WPF issues you'll be better off posting in the WPF forum. I suspect you're running into the known issue described in this thread on that forum rather than to anything specific to touch injection.

    --Rob

    Thursday, June 13, 2013 2:26 AM