how to listen global touch events even form isnt focused

Viewed 365

I found that

[DllImport("user32.dll")]
static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc callback, IntPtr hInstance, uint threadId);

will be able to capture global touch event and does exactly what I'm looking for (return x,y and tell me if this is coming from touch not mouse). but! I want to get multiple touch events. SetWindowsHookEx gives me only one touch. When there are 3 touches moving on the screen, I want to be able to get all 3 touches and their coords.

I found these might help

[DllImport("User32.dll")]
internal static extern uint GetRawInputData(IntPtr hRawInput, uint uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader);

[DllImport("User32.dll")]
internal static extern bool RegisterRawInputDevices(RAWINPUTDEVICE[] pRawInputDevice, uint uiNumDevices, uint cbSize);

[DllImport("User32.dll")]
internal static extern uint GetRawInputDeviceList(IntPtr pRawInputDeviceList, ref uint uiNumDevices, uint cbSize);

[DllImport("User32.dll")]
internal static extern uint GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize);

but i'm very new to c# and have no clue how to utilize those. I was getting 9 devices when called GetRawInputDeviceList() but not able to tell which one is the touchscreen. even if I do, I still don't know how to track all the touches. detailed example would be super appreciated.

0 Answers
Related