Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 8 - Simulate touchscreen events

What would be the best approach to simulate a user tapping on a touchscreen of a Windows Phone 8 device?

One approach I could imagine is to use native code to call the Win32 API functions which control the mouse events. This would assume that touchscreen events are more or less the same as mouse events, and that these API functions are accessible. Does anyone know if this is the case on WP8?

Another approach would be to have something like the Android ADB for the Windows Phone. On Android, one can use ADB to control the device from the PC and also simulate touch screen events (e.g. via Monkeyrunner). I haven't found any information if there is a tool like ADB for Windows Phone 8.

The purpose of finding a solution for this is the integration of Windows Phone 8 devices in an automated testing process.

like image 247
jakob.j Avatar asked Dec 07 '12 14:12

jakob.j


1 Answers

I found out that there is a DLL file named InputInjection.dll in the System32 folder of the Windows Phone 8 (at least in the simulator image I mounted).

This library contains the following functions:

  • ApiInjectInitialize
  • ApiInjectTouchEvent
  • ApiInjectButtonEvent
  • ApiInjectEnableExclusive
  • ApiInjectUninitialize

InputInjection.dll in Dependency Walker

Doing some research, I found out that there are official ways to simulate touch input for Windows 8 development:

  • http://social.technet.microsoft.com/wiki/contents/articles/6460.simulating-touch-input-in-windows-8-preview-versions-using-touch-injection-api-en-us.aspx
  • http://msdn.microsoft.com/library/windows/desktop/hh802896(v=vs.85).aspx

However, the functions used for Windows 8 development are not available on Windows Phone 8. But the functions are named similarly to the ones I found in InputInjection.dll:

  • InitializeTouchInjection similar to ApiInjectInitialize
  • InjectTouchInput similar to ApiInjectTouchEvent
  • (...)

I wasn't able to find any documentation on InputInjection.dll and its functions. These functions also don't appear in the header files of the SDK. Maybe Microsoft uses these functions internally for their own tests during Windows Phone development.

The question is: Is it possible to access this library and call these functions somehow? This would be similar to using "Private APIs" on iOS, I guess. I tried several ways to achieve this with a Windows Phone 8 app using native C++ code, but I had no luck so far (the basic reason is that the apps run sandboxed on Windows Phone). Is there any way to get a binary running on Windows Phone (maybe via a debug bridge or something)?

like image 58
jakob.j Avatar answered Sep 30 '22 02:09

jakob.j