RegisterPointerInputTarget() breaks InjectTouchInput() on Windows 8.1 when the user physically touches the screen.

This is a "working on Windows 8.0 but broken on 8.1" problem.
My application is a full screen magnifier. When magnification is turned on, there is no longer a 1:1 relationship between touch screen coordinates and desktop coordinates.
So I need a way to allow the user operate the computer, such as dragging or pinching something on the desktop (icon/window/whatever). So when they drag their finger(s) across the touch screen, I need to capture that, translate the touch coordinates from magnified
pixels coordinates into original desktop pixels and then inject new input to the app. I also want the ability to capture the touch input and not pass it to the app (so I can have gestures/whatever to control the magnifier viewport location). I might also want
to inject input when the user is not touching the real screen.
So I am capturing all touch input RegisterPointerInputTarget() and simulating touch input using InjectTouchInput() (after translating coordinates from the screen to the magnified desktop).
My code for simulating touch input works fine in isolation (as does the SDK sample). My code for capturing all touch input also works fine. However, if they are both used at the same time it’s not happy, although I am not getting any error codes back from the
API.
Specifically, attempts to simulate a touch and hold or a touch and drag are not working whenever the user is physically touching the real touch screen. Further diagnosis indicates that the touch input messages are not arriving in the target application. The
moment the user physcially touches the screen, any simulated input in progress gets cancelled and all subsequent calls to InjecttouchInput() are ignored - but no error code is returned.
Because I am capturing all real input using RegisterPointerInputTarget(), I would expect all real physical input to be redirected to my window (which it does) and be able to call InjectTouchInput() at any point to simulate input. The simulated input would go
to the target app and not be captured by my own process.
This all worked fine in Windows 8.0 but is broken in  windows 8.1.
I have written a basic test application that does two things.
1.       Uses RegisterPointerInputTarget() to consume all touch input.
2.       Uses InjectTouchInput() to simulate some output. In this case, it just does a click, followed by a down, a drag and an up – which handily draws a line in the paint application if you arrange your windows carefully.
If I run this, it works until you physically touch the screen with your finger. The moment you do this, InjectTouchInput stops working (no error code), but the paint app receives a mouse up and the line stops. The hwnd to capture all touch input does receive
WM_POINTER... messages and I an returning 0 from this function (have tried other return codes, nothing makes any difference).
So it looks like that if you use RegisterPointerInputTarget(), any physical input is captured, but it also breaks any simulated touch gestures that are currently in progress.
Source code is below, which you can drop in as a replacement for the main .cpp file in your injecttouch sample code from the win8 sdk (and set uiaccess=true and code sign it!). It does it in two threads, however this doesn’t seem to matter, it does the same
thing with one thread. Am I doing something wrong?  (and yes, I know that calling Sleep() is not wise - my real app doesn't do this)?
- Mike.
// allow use of Windows 8 headers
#undef WINVER
#define WINVER 0x0602
#include "stdafx.h"
#include <debugoutx.h>
#include <process.h>
* WinMain *
* Application entrypoint *
static HWND touch_hwnd = NULL;
static ATOM touch_window_atom = NULL;
LRESULT CALLBACK TouchThread_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
switch (message)
case WM_CLOSE:
DestroyWindow(hWnd);
touch_hwnd = NULL;
break;
case WM_NCPOINTERUPDATE :
case WM_NCPOINTERDOWN :
case WM_NCPOINTERUP :
case WM_POINTERENTER :
case WM_POINTERLEAVE :
case WM_POINTERACTIVATE :
case WM_POINTERCAPTURECHANGED :
case WM_TOUCHHITTESTING :
case WM_POINTERWHEEL :
case WM_POINTERHWHEEL :
// case DM_POINTERHITTEST :
case 0x250:
case WM_POINTERUPDATE :
case WM_POINTERDOWN :
case WM_POINTERUP :
// consume pointer mesages
dprintf(L"msg %x\n",message);
return 0;
break;
case WM_TIMER:
break;
default:
dprintf(L"msg %x\n",message);
return DefWindowProc(hWnd, message, wParam, lParam);
break;
return 0;
void Inject(POINTER_TOUCH_INFO &contact)
Sleep(1);
while(1)
DWORD bRet = InjectTouchInput(1, &contact);
if (bRet==0)
DWORD temp = GetLastError();
if (temp==ERROR_NOT_READY)
Sleep(1);
continue;
else
DebugBreak();
break;
static int start = 400;
static int end = 800;
bool SimulateInput(POINTER_TOUCH_INFO &contact)
static int x = start;
if (x==start)
contact.pointerInfo.ptPixelLocation.x = x;
// inject a touch down
contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
Inject(contact);
else if (x==(start+1))
Sleep(10);
contact.pointerInfo.pointerFlags = POINTER_FLAG_UP ;
Inject(contact);
else if (x==(start+2))
contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
Inject(contact);
else if (x==end)
contact.pointerInfo.pointerFlags = POINTER_FLAG_UP ;
Inject(contact);
PostMessage(touch_hwnd,WM_QUIT,0,0);
return false;
else if (x<end)
// drag
contact.pointerInfo.ptPixelLocation.x = x;
// contact.rcContact.left = x - 4;
// contact.rcContact.right = x + 4;
contact.pointerInfo.pointerFlags = POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;;
Inject(contact);
x++;
return true;
void thread2(void *)
// create window to capture global touch input.
if (!touch_window_atom)
WNDCLASS wc;
wc.style = 0; // Class style(s).
wc.lpfnWndProc = TouchThread_WndProc; // Function to retrieve messages
wc.cbClsExtra = 0; // No per-class extra data.
wc.cbWndExtra = 0; // No per-window extra data.
wc.hInstance = GetModuleHandle(0); // Application that owns the class.
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL; // Name of menu resource in .RC file.
wc.lpszClassName = L"MarsTouchInputCapture"; // Name used in call to CreateWindow.
// Register the window class and return success/failure code.
touch_window_atom = RegisterClass(&wc);
touch_hwnd = CreateWindowEx(WS_EX_NOACTIVATE,L"MarsTouchInputCapture",L"Magnification",0,0,0,1,1,NULL,NULL,GetModuleHandle(0),NULL);
// capture global desktop touch input
if (RegisterPointerInputTarget(touch_hwnd,PT_TOUCH)==0)
DWORD err = GetLastError();
MessageBox(NULL,L"RegisterPointerInputTarget(PT_TOUCH) failed",L"error",MB_OK);
if (RegisterPointerInputTarget(touch_hwnd,PT_PEN)==0)
DWORD err = GetLastError();
MessageBox(NULL,L"RegisterPointerInputTarget(PT_PEN) failed",L"error",MB_OK);
// message loop
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
DispatchMessage(&msg);
UnregisterPointerInputTarget(touch_hwnd,PT_TOUCH);
UnregisterPointerInputTarget(touch_hwnd,PT_PEN);
int
WINAPI WinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nShowCmd)
POINTER_TOUCH_INFO contact;
BOOL bRet = TRUE;
MessageBox(NULL,L"Break on Load",L"Attach Debugger",MB_OK);
// assume a maximum of 10 contacts and turn touch feedback off
InitializeTouchInjection(10, TOUCH_FEEDBACK_NONE);
// initialize the touch info structure
memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
contact.pointerInfo.pointerType = PT_TOUCH; //we're sending touch input
contact.pointerInfo.pointerId = 7; //contact 0
contact.pointerInfo.ptPixelLocation.x = 400;
contact.pointerInfo.ptPixelLocation.y = 480;
contact.touchFlags = TOUCH_FLAG_NONE;
contact.touchMask = TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
contact.touchMask = 0;
contact.orientation = 90;
contact.pressure = 32000;
// create thread/window for global capture
_beginthread(thread2,0,NULL);
while(SimulateInput(contact))
Sleep(1);
return 0;

I have almost same situation. But there are some different. I am using RegisterPointerInputTarget to redirect all touch message to my window. and use InjectTouchInput to simulate each flag, which means, WM_POINTERDOWN,WM_POINTERUPDATE,WM_POINTERUP. If user
touches monitor, I simulate DOWN, if user swipes their finger, I simulate UPDATE, if user lifts finger, I simulate UP.
Then the interesting point is, system consider user's finger as primary pointer, and my injected touch as secondary pointer. windows desktop and windows explorer skip all my injected touch. I really hate that.
However IE and chrome will accept my injected touch, they don't caret about primary pointer.
In order to fix this problem, I call AccNotifyTouchInteraction before calling InjectTouchInput.
According to the MSDN, AccNotifyTouchInteraction will notify the destination window before InjectTouchInput. But this idea still fails, which is disappointing.

Similar Messages

  • How can I access files from a flash drive that were previously saved using a Windows computer? When I attempt to open the file on MacBook Pro, it is asking to "convert file to"; I also have Microsoft Word installed on the Mac as well.

    How can I access files from a flash drive that were previously saved using a Windows computer? When I attempt to open the file on MacBook Pro, it is asking to "convert file to"; none of the options I choose work. I also have Microsoft Office (with Word) installed on the Mac as well.

    Format the external drive as FAT32 or ExFAT. Both computers will then be able to read and write to it.

  • Where has my airport utility window gone ? when I double click on the icon all I get is an image of a globe and a base station with no options to make changes in my airport extreme.

    Where has my airport utility window gone? When I double click on the airport utility icon all I get is a picture of a globe and a base station with no further  options available to modify my airport extreme. 

    Sorry, you lost me on that last post.
    Let's start over again.
    Open AirPort Utility on your Mac
    Are you asked for a password at this point?  If yes, enter the base station or device password that you used when you originally set up the AirPort router. Depending when you did this originally, you might have been given an option to use the same password as the wireless network. If you were not, then you have a separate password for the base station.
    You need that password to be able to access the settings for the AirPort router in AirPort Utility.
    If you see a window listing basic information, click Edit in the upper right corner of the window.
    If you are asked for a password, you must enter the device password or base station password that you established when you first set up the AirPort router as explained above.
    If you forgot the password, a Soft Reset will allow you to go in and reset the base station password.  Might be a good idea to write down that password.
    If you are still stuck, then the only option that you have at this point is to perform a Hard Reset to return the settings to factory defaults and then set up the AirPort router again.
    If you prefer, you can also do a Factory Default Reset. It's the same as a Hard Reset except for the timing of holding in the reset button.

  • I have a mid 2009 macbook pro and my issue is that I installed windows 7 and when I wan to install the drivers it says " bootcamp x64 is unsupported on this computer model" I tried installing the drivers with the bootcamp 4 but it did not work either

    I have a mid 2009 macbook pro and my issue is that I installed windows 7 and when I wan to install the drivers it says " bootcamp x64 is unsupported on this computer model" I tried installing the drivers with the bootcamp 4 but it did not work either it says that i have a newer bootcamp version. I tried a few tricks but they didnot work. I hope to be helped

    Welcome to Apple Support Communities
    You can install a 64-bit Windows 7 or Vista version in your Mac. Make sure you downloaded these drivers > http://support.apple.com/kb/DL1630 Also, if you have the Snow Leopard DVD you used to upgrade your Mac or the OS X DVD that came with your Mac, you can use it to install the Boot Camp drivers

  • IPlanet 6.0 SP2 restart on Windows NT when a user logs off the server.

    UPDATE: We have found that the iWS 6.0 only restart with JDK 1.3.1 installed for JSP pages. What is the best JDK to use?
    iPlanet 6.0 SP2 restart on Windows NT when a user logs off the server. If a admin or joe developer logs into the server (C+A+D) and does what ever... When the
    person logs off the NT 4.0 box ... ALL the httpd process restart. We have 80 & 443 & Admin. The processes are running under a user account. Any one have an idea why the process are restarting?"

    Hi,
    You can use following JDK version for Windows NT.
    And please check it out whether WinNT-SP6 as been installed in winNT box.
    Window NT:
    SDK and JRE 1.4 http://java.sun.com/j2se/1.4/
    SDK and JRE 1.3.1_02 http://java.sun.com/j2se/1.3/
    SDK and JRE 1.2.2_011 http://java.sun.com/products/jdk/1.2/
    JDK and JRE 1.1.8_009
    http://java.sun.com/products/jdk/1.1/download-jdk-windows.html
    I hope this helps.
    Regards,
    Dakshin.
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support.

  • I've downloaded ADE 4.0.3, apparently successfully, and I 'Close the 'Completed' window. But, when I attend to run the program, I get an hourglass for about 2 seconds and then ... ... nothing! Clearly I can't authorize my computer for download. Ideas?

    I've downloaded ADE 4.0.3, apparently successfully, and I 'Close the 'Completed' window. But, when I attend to run the program, I get an hourglass for about 2 seconds and then ... ... nothing! Clearly I can't authorize my computer for download. Ideas?

    Try restarting your machine and Launch ADE again

  • Datatip function not shown when the user hovers over the icon int ADG

    When you have a datatip function in a advanced datagrid the datatip  does not show when the user hovers over the icon. Is there a way round this?

    I have almost same situation. But there are some different. I am using RegisterPointerInputTarget to redirect all touch message to my window. and use InjectTouchInput to simulate each flag, which means, WM_POINTERDOWN,WM_POINTERUPDATE,WM_POINTERUP. If user
    touches monitor, I simulate DOWN, if user swipes their finger, I simulate UPDATE, if user lifts finger, I simulate UP.
    Then the interesting point is, system consider user's finger as primary pointer, and my injected touch as secondary pointer. windows desktop and windows explorer skip all my injected touch. I really hate that.
    However IE and chrome will accept my injected touch, they don't caret about primary pointer.
    In order to fix this problem, I call AccNotifyTouchInteraction before calling InjectTouchInput.
    According to the MSDN, AccNotifyTouchInteraction will notify the destination window before InjectTouchInput. But this idea still fails, which is disappointing.

  • Message (on one account) when logging in: The user account running the Configuration Manager console has insufficient permissions to read information from the Configuration Manager site database.

    After installing the reportservice/database i cannot use the Configuration Manager Console 2012 anymore with my own AD account. (The accounts of my colleagues are stil working)
    When i login i get the following message:
    The user account running the Configuration Manager console has insufficient permissions to read information from the Configuration Manager site database. The account must belong to a security role in Configuration Manager. The account must also have
    the Windows Server Distributed Component Object Model (DCOM) Remote Activation permission for the computer running the Configuration Manager site server and the SMS Provider.
    I checked the following:
    I am a administrative user in SCCM (Full Administrator)
    I am a member of the administrator group on the server
    Deleted HKEY_CURRENT_USER\Software\Microsoft\ConfigMgr10
    I tried to start it on multiple workstations and deleted my roaming profile
    Any more suggestions?

    Hi,
    Maybe you could have a look on the below blog.
    http://blog.nimbo.com/how-to-disable-user-account-control-in-windows-server-2012/
    (Note: Microsoft provides third-party contact information to help you find technical support. This contact information
    may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.)
    Best Regards,
    Joyce Li
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • When the user click on the request number it should skip the first screen o

    when the user click on the request number it should skip the first screen of REV track and show the rev track request number details. On click of u201CBacku201D button on this screen the output screen of the report should be displayed again.

    Hello Rohit,
                   What you can do is, when the User Clicks on any particular Request, you use the At Line-Selection Event. In that event, you can set the User Name to default "SY-UNAME" or any other user Name for the specific Request.
                 Again, if you want to check the Owner of the Request, you can use the Table E070 where you can Input the Request Number and get the Owner of the Request. Set the same in the User Name Field and Skip First Screen (SE09 Transaction).
    Hope it was helpful.
    Thanks and Regards,
    Venkat Phani Prasad Konduri

  • 'File in Use' message is received when one user is in the report and another user tries to open the Excel template

    ‘File in Use’ message is received when one user is in the report and another user tried to open the excel template. how to make excel template shared for multiple users so the users don’t see the ‘File in Use’ message?

    Hi Febin,
    In addition to others’ replies, we can create a shared workbook and place it on a network location where several people can
    edit the contents simultaneously. For example, if the people in your work group each handle several projects and need to know the status of each other's projects, the group can use a shared workbook to track the status of the projects. All persons involved
    can then enter the information for their projects in the same workbook.
    Regarding how to do this,
     the following article can be referred to reference.
    Use a shared workbook to collaborate
    http://office.microsoft.com/en-in/excel-help/use-a-shared-workbook-to-collaborate-HP010096833.aspx
    Best regards,
    Frank Shen

  • Can web content overlay  refresh when a user re-enters the page?

    I have a page that has  a web content overlay that id like to refresh when a user re-enters the page.
    To be exact i have a photswipe gallery that works great butid like it to restart from the beginning when a user renters the page

    There is no simple way to disable swiping to a new page. You could put an empty scrolling frame in, I suppose, but I don’t see how that would make the reader’s experience very good.
    Bob

  • When syncing my ipod touch, the Other category shows it's taking up a lot of space.  What is in Other?

    When syncing my iPod Touch, the "Other" category shows it's taking up a large amount of storage space on the device.  What is in the "Other" category, and how do I control what goes into it?

    Restore from a backup will get you some 'other' back.
    Still not happy, Restore in iTunes, Setup as new. Sync back personal data using iTunes Tabs

  • I've seen sparks when peripherals, specifically the printer connection, touch the metal back of the machine. I've also felt a mild charge from the microphone I've plugged in. Could that be a problem?

    I've seen sparks when peripherals, specifically the printer connection, touch the metal back of the machine. I've also felt a mild charge from the microphone I've plugged in. Could that be a problem?

    Are you using a three pronged grounded outlet that you know is properly grounded?

  • How can I create a scrolling effect where when the user scrolls down the image will blur out?

    How can I create a scrolling effect where when the user scrolls down the image will blur out?

    Hi there,
    You can create a scroll motion where the image will fade out on scrolling, you need to use the Opacity tab under Scroll Effects Panel.
    If you particularly need the image to be blur out, then you need to edit that image in any image editing program and make one copy of that image as blurred, then place both images (actual and blurred) on that page and use scroll motion or fade option to replace images.

  • I'm running on Windows 8. When I connect my iphone the system opens the photo downloader and itunes doesn't see the iphone

    When I connect my iphone the laptop open the photo dowloading software & itunes doesn't seem to see the iphone.

    Hello Jim,
    I would be concerned as well if my iPhone was not recognized by iTunes. I recommend the following article to troubleshoot the issue you described:
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

Maybe you are looking for

  • Unable to delete data files from my Ipod if used as data storage...

    Hello everybody I bought months ago an Ipod Nano 8GB. I've got an issue when i use it as disk storage i'm not able to sort out. I've checked all the topics but i cannot find any solution. Example: I use the Ipod with the option "Manually manage music

  • Cash Flow summary report

    Hi All, The user was trying to run the following report. Report: ZKIOR095 Description This report is a variant of the cash flow report for use by the ngineering department. The report is unique because it mixes both actuals and budget on a given line

  • Opening the cd drive if the computer is off

    good morning- i'm trying to open my cd drive while the computer is off in order to a disk repair from the os x installation disk. how do i get it open? do i use a pin in the little hole? just wanted check before i start poking around. thanks. jesse

  • Mac book turned on all the time.

    Hey there. I was wondering if that is a problem if I keep my mbp turned on for 2-3 days on. Is it harmless for the battery? Thank you.

  • Goods Issue via SDK

    Hi guys, I would like to create a Goods Issue (Stock Management->Stock transactions->Goods Issue) using the DI API. What object am I supposed to use? eg: private SAPbobsCOM.GoodsIssue; Regards, Costas