我要做一個功能,全域截取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);
}
uj5u.com熱心網友回復:
對了 作業系統是windonws 10uj5u.com熱心網友回復:
用鉤子肯定是可行的,可以參考gestrueSign的開源代碼uj5u.com熱心網友回復:
有更詳細的提示嗎? 搜不到 什么關于 gestrueSign 的資料。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/79845.html
標籤:Windows客戶端使用
下一篇:磁盤磁區空間丟失
