1
有沒有什麼方法可以在電阻式觸摸屏設備上模擬Windows 8手勢(縮放,旋轉,滑動)?Windows 8 - 在電阻式觸摸屏上使用c#模擬手勢
我的設置是一個典型的桌面Windows 8應用程序,目標是2種屏幕類型(電阻式和電容式觸摸屏)。在電阻式屏幕上,多點觸控手勢無法識別,可以使用鍵盤組合或映射鍵(此設備上沒有附帶鼠標)完成。
有沒有什麼方法可以在電阻式觸摸屏設備上模擬Windows 8手勢(縮放,旋轉,滑動)?Windows 8 - 在電阻式觸摸屏上使用c#模擬手勢
我的設置是一個典型的桌面Windows 8應用程序,目標是2種屏幕類型(電阻式和電容式觸摸屏)。在電阻式屏幕上,多點觸控手勢無法識別,可以使用鍵盤組合或映射鍵(此設備上沒有附帶鼠標)完成。
Windows 8提供本機touch injection函數InitializeTouchInjection和InjectTouchInput,您可以從C#調用來合成可以轉換爲手勢的指針輸入。
Input: Touch injection sample在C++中演示了這一點。由PInvoke Interop Assistant
public partial class NativeConstants {
/// TOUCH_FLAG_NONE -> 0x00000000
public const int TOUCH_FLAG_NONE = 0;
/// TOUCH_MASK_NONE -> 0x00000000
public const int TOUCH_MASK_NONE = 0;
/// TOUCH_MASK_CONTACTAREA -> 0x00000001
public const int TOUCH_MASK_CONTACTAREA = 1;
/// TOUCH_MASK_ORIENTATION -> 0x00000002
public const int TOUCH_MASK_ORIENTATION = 2;
/// TOUCH_MASK_PRESSURE -> 0x00000004
public const int TOUCH_MASK_PRESSURE = 4;
/// POINTER_FLAG_NONE -> 0x00000000
public const int POINTER_FLAG_NONE = 0;
/// POINTER_FLAG_NEW -> 0x00000001
public const int POINTER_FLAG_NEW = 1;
/// POINTER_FLAG_INRANGE -> 0x00000002
public const int POINTER_FLAG_INRANGE = 2;
/// POINTER_FLAG_INCONTACT -> 0x00000004
public const int POINTER_FLAG_INCONTACT = 4;
/// POINTER_FLAG_FIRSTBUTTON -> 0x00000010
public const int POINTER_FLAG_FIRSTBUTTON = 16;
/// POINTER_FLAG_SECONDBUTTON -> 0x00000020
public const int POINTER_FLAG_SECONDBUTTON = 32;
/// POINTER_FLAG_THIRDBUTTON -> 0x00000040
public const int POINTER_FLAG_THIRDBUTTON = 64;
/// POINTER_FLAG_FOURTHBUTTON -> 0x00000080
public const int POINTER_FLAG_FOURTHBUTTON = 128;
/// POINTER_FLAG_FIFTHBUTTON -> 0x00000100
public const int POINTER_FLAG_FIFTHBUTTON = 256;
/// POINTER_FLAG_PRIMARY -> 0x00002000
public const int POINTER_FLAG_PRIMARY = 8192;
/// POINTER_FLAG_CONFIDENCE -> 0x00004000
public const int POINTER_FLAG_CONFIDENCE = 16384;
/// POINTER_FLAG_CANCELED -> 0x00008000
public const int POINTER_FLAG_CANCELED = 32768;
/// POINTER_FLAG_DOWN -> 0x00010000
public const int POINTER_FLAG_DOWN = 65536;
/// POINTER_FLAG_UPDATE -> 0x00020000
public const int POINTER_FLAG_UPDATE = 131072;
/// POINTER_FLAG_UP -> 0x00040000
public const int POINTER_FLAG_UP = 262144;
/// POINTER_FLAG_WHEEL -> 0x00080000
public const int POINTER_FLAG_WHEEL = 524288;
/// POINTER_FLAG_HWHEEL -> 0x00100000
public const int POINTER_FLAG_HWHEEL = 1048576;
/// POINTER_FLAG_CAPTURECHANGED -> 0x00200000
public const int POINTER_FLAG_CAPTURECHANGED = 2097152;
/// POINTER_FLAG_HASTRANSFORM -> 0x00400000
public const int POINTER_FLAG_HASTRANSFORM = 4194304;
}
public enum tagPOINTER_INPUT_TYPE {
/// PT_POINTER -> 0x00000001
PT_POINTER = 1,
/// PT_TOUCH -> 0x00000002
PT_TOUCH = 2,
/// PT_PEN -> 0x00000003
PT_PEN = 3,
/// PT_MOUSE -> 0x00000004
PT_MOUSE = 4,
/// PT_TOUCHPAD -> 0x00000005
PT_TOUCHPAD = 5,
}
public enum tagPOINTER_BUTTON_CHANGE_TYPE {
POINTER_CHANGE_NONE,
POINTER_CHANGE_FIRSTBUTTON_DOWN,
POINTER_CHANGE_FIRSTBUTTON_UP,
POINTER_CHANGE_SECONDBUTTON_DOWN,
POINTER_CHANGE_SECONDBUTTON_UP,
POINTER_CHANGE_THIRDBUTTON_DOWN,
POINTER_CHANGE_THIRDBUTTON_UP,
POINTER_CHANGE_FOURTHBUTTON_DOWN,
POINTER_CHANGE_FOURTHBUTTON_UP,
POINTER_CHANGE_FIFTHBUTTON_DOWN,
POINTER_CHANGE_FIFTHBUTTON_UP,
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct tagPOINTER_INFO {
/// POINTER_INPUT_TYPE->DWORD->unsigned int
public uint pointerType;
/// UINT32->unsigned int
public uint pointerId;
/// UINT32->unsigned int
public uint frameId;
/// POINTER_FLAGS->UINT32->unsigned int
public uint pointerFlags;
/// HANDLE->void*
public System.IntPtr sourceDevice;
/// HWND->HWND__*
public System.IntPtr hwndTarget;
/// POINT->tagPOINT
public Point ptPixelLocation;
/// POINT->tagPOINT
public Point ptHimetricLocation;
/// POINT->tagPOINT
public Point ptPixelLocationRaw;
/// POINT->tagPOINT
public Point ptHimetricLocationRaw;
/// DWORD->unsigned int
public uint dwTime;
/// UINT32->unsigned int
public uint historyCount;
/// INT32->int
public int inputData;
/// DWORD->unsigned int
public uint dwKeyStates;
/// UINT64->unsigned __int64
public ulong PerformanceCount;
/// POINTER_BUTTON_CHANGE_TYPE->tagPOINTER_BUTTON_CHANGE_TYPE
public tagPOINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct tagPOINTER_TOUCH_INFO {
/// POINTER_INFO->tagPOINTER_INFO
public tagPOINTER_INFO pointerInfo;
/// TOUCH_FLAGS->UINT32->unsigned int
public uint touchFlags;
/// TOUCH_MASK->UINT32->unsigned int
public uint touchMask;
/// RECT->tagRECT
public tagRECT rcContact;
/// RECT->tagRECT
public tagRECT rcContactRaw;
/// UINT32->unsigned int
public uint orientation;
/// UINT32->unsigned int
public uint pressure;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct Point {
/// LONG->int
public int x;
/// LONG->int
public int y;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct tagRECT {
/// LONG->int
public int left;
/// LONG->int
public int top;
/// LONG->int
public int right;
/// LONG->int
public int bottom;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct HWND__ {
/// int
public int unused;
}
public partial class NativeMethods {
/// Return Type: BOOL->int
///maxCount: UINT32->unsigned int
///dwMode: DWORD->unsigned int
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="InitializeTouchInjection")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool InitializeTouchInjection(uint maxCount, uint dwMode) ;
/// Return Type: BOOL->int
///count: UINT32->unsigned int
///contacts: POINTER_TOUCH_INFO*
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="InjectTouchInput")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool InjectTouchInput(uint count, ref tagPOINTER_TOUCH_INFO contacts) ;
}
產生
對調用簽名