关于 RegisterPointerInputTarget 的问题
我要做一个功能,全局截取windows的多点触摸事件。
https://stackoverflow.com/questions/14297322/how-to-detect-tapping-touch-input-globally-instead-of-mouse-clicking
这个地方提供了三种方式,第一种HID方式不适合自己要开发应用的情况,第三种用钩子的方式,试过了也是有问题。
所以觉得第二种采用RegisterPointerInputTarget的方式最可行。
但是测试下来,每次执行RegisterPointerInputTarget都失败,一直返回ERROR_ACCESS_DENIED。
uiAccess=true也设置过了。
看过这个帖子,发帖人说单独截取能成功,所以就采用了他的截取触摸事件的代码。
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/4bcc48a3-7131-4d2a-b46f-ea8992d00ea8/injecttouchinput-and-registerpointerinputtarget-not-work-successfully-on-windows-10-anniversary?forum=windowscompatibility
这方面的资料几乎翻了个遍都没找到合适的解决办法,有哪位大神经历过,求解决办法。
代码:
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = TouchThread_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(0);
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = L"MarsTouchInputCapture";
RegisterClass(&wc);
touch_hwnd = CreateWindowEx(WS_EX_NOACTIVATE, L"MarsTouchInputCapture", L"Magnification", 0, 0, 0, 10000, 10000, NULL, NULL, GetModuleHandle(0), 0);
//RegisterTouchWindow(touch_hwnd, TWF_WANTPALM);
if (RegisterPointerInputTarget(touch_hwnd, PT_TOUCH) == 0)
{
DWORD err = GetLastError();
cout << err << endl;
MessageBox(NULL, L"RegisterPointerInputTarget(PT_TOUCH) failed", L"error", MB_OK);
}
void endGlobalTouch()
{
UnregisterPointerInputTarget(touch_hwnd, PT_TOUCH);
}