Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ctypes import *
- from ctypes.wintypes import *
- #####################################################################################
- class RawInputError (RuntimeError) :
- """ RawInput Errors """
- class RAWINPUTDEVICE (Structure) :
- _fields_ = [
- ("usUsagePage", WORD),
- ("usUsage", WORD),
- ("dwFlags", DWORD),
- ("hwndTarget", HWND),
- ]
- class RAWINPUTDEVICELIST (Structure) :
- _fields_ = [
- ("hDevice", HANDLE),
- ("dwType", DWORD),
- ]
- class RAWINPUTHEADER (Structure) :
- _fields_ = [
- ("dwType", DWORD),
- ("dwSize", DWORD),
- ("hDevice", HANDLE),
- ("wParam", WPARAM),
- ]
- class RAWMOUSE (Structure) :
- class _U1 (Union) :
- class _S2 (Structure) :
- _fields_ = [
- ("usButtonFlags", WORD),
- ("usButtonData", SHORT),
- ]
- _fields_ = [
- ("ulButtons", ULONG),
- ("_s2", _S2),
- ]
- _fields_ = [
- ("usFlags", WORD),
- ("_u1", _U1),
- ("ulRawButtons", ULONG),
- ("lLastX", LONG),
- ("lLastY", LONG),
- ("ulExtraInformation", ULONG),
- ]
- _anonymous_ = ("_u1", )
- class RAWKEYBOARD (Structure) :
- _fields_ = [
- ("MakeCode", WORD),
- ("Flags", WORD),
- ("Reserved", WORD),
- ("VKey", WORD),
- ("Message", UINT),
- ("ExtraInformation", ULONG),
- ]
- class RAWHID (Structure) :
- _fields_ = [
- ("dwSizeHid", DWORD),
- ("dwCount", DWORD),
- ("bRawData", BYTE),
- ]
- class RAWINPUT (Structure) :
- class _U1 (Union) :
- _fields_ = [
- ("mouse", RAWMOUSE),
- ("keyboard", RAWKEYBOARD),
- ("hid", RAWHID),
- ]
- _fields_ = [
- ("header", RAWINPUTHEADER),
- ("_u1", _U1),
- ("hDevice", HANDLE),
- ("wParam", WPARAM),
- ]
- _anonymous_ = ("_u1", )
- class RID_DEVICE_INFO_MOUSE (Structure) :
- _fields_ = [
- ("dwId", DWORD),
- ("dwNumberOfButtons", DWORD),
- ("dwSampleRate", DWORD),
- ]
- class RID_DEVICE_INFO_KEYBOARD (Structure) :
- _fields_ = [
- ("dwType", DWORD),
- ("dwSubType", DWORD),
- ("dwKeyboardMode", DWORD),
- ("dwNumberOfFunctionKeys", DWORD),
- ("dwNumberOfIndicators", DWORD),
- ("dwNumberOfKeysTotal", DWORD),
- ]
- class RID_DEVICE_INFO_HID (Structure) :
- _fields_ = [
- ("dwVendorId", DWORD),
- ("dwProductId", DWORD),
- ("dwVersionNumber", DWORD),
- ("usUsagePage", USHORT),
- ("usUsage", USHORT),
- ]
- class RID_DEVICE_INFO (Structure) :
- class _U1 (Union) :
- _fields_ = [
- ("mouse", RID_DEVICE_INFO_MOUSE),
- ("keyboard", RID_DEVICE_INFO_KEYBOARD),
- ("hid", RID_DEVICE_INFO_HID),
- ]
- _fields_ = [
- ("cbSize", DWORD),
- ("dwType", DWORD),
- ("_u1", _U1),
- ]
- _anonymous_ = ("_u1", )
- #####################################################################################
- RIDEV_REMOVE = 0x00000001
- RIDEV_EXCLUDE = 0x00000010
- RIDEV_PAGEONLY = 0x00000020
- RIDEV_NOLEGACY = 0x00000030
- RIDEV_INPUTSINK = 0x00000100
- RIDEV_CAPTUREMOUSE = 0x00000200 # effective when mouse nolegacy is specified, otherwise it would be an error
- RIDEV_NOHOTKEYS = 0x00000200 # effective for keyboard.
- RIDEV_APPKEYS = 0x00000400 # effective for keyboard.
- RIDEV_EXMODEMASK = 0x000000F0
- RIDI_PREPARSEDDATA = 0x20000005
- RIDI_DEVICENAME = 0x20000007 # the return valus is the character length, not the byte size
- RIDI_DEVICEINFO = 0x2000000b
- RID_INPUT = 0x10000003
- RID_HEADER = 0x10000005
- RIM_TYPEMOUSE = 0
- RIM_TYPEKEYBOARD = 1
- RIM_TYPEHID = 2
- RI_MOUSE_LEFT_BUTTON_DOWN = 0x0001 # Left Button changed to down.
- RI_MOUSE_LEFT_BUTTON_UP = 0x0002 # Left Button changed to up.
- RI_MOUSE_RIGHT_BUTTON_DOWN = 0x0004 # Right Button changed to down.
- RI_MOUSE_RIGHT_BUTTON_UP = 0x0008 # Right Button changed to up.
- RI_MOUSE_MIDDLE_BUTTON_DOWN = 0x0010 # Middle Button changed to down.
- RI_MOUSE_MIDDLE_BUTTON_UP = 0x0020 # Middle Button changed to up.
- RI_MOUSE_WHEEL = 0x0400
- MOUSE_MOVE_RELATIVE = 0
- MOUSE_MOVE_ABSOLUTE = 1
- MOUSE_VIRTUAL_DESKTOP = 0x02 # the coordinates are mapped to the virtual desktop
- MOUSE_ATTRIBUTES_CHANGED = 0x04 # requery for mouse attributes
- #####################################################################################
- RegisterRawInputDevices = windll.user32.RegisterRawInputDevices
- GetRawInputData = windll.user32.GetRawInputData
- GetRawInputDeviceList = windll.user32.GetRawInputDeviceList
- GetRawInputDeviceInfo = windll.user32.GetRawInputDeviceInfoA
- #################################### End Of File ####################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement