コード例 #1
0
 def WindowProc(self, hwnd, mesg, wParam, lParam):
     if mesg not in self.messageProcs:
         return DefWindowProc(hwnd, mesg, wParam, lParam)
     for handler in self.messageProcs[mesg]:
         res = handler(hwnd, mesg, wParam, lParam)
         if res == 0:
             return 0
     return 1
コード例 #2
0
ファイル: __init__.py プロジェクト: WoLpH/EventGhost
 def OnRawInput(self, hwnd, mesg, wParam, lParam):
     pcbSize = UINT()
     GetRawInputData(
         lParam, RID_INPUT, None, byref(pcbSize), sizeof(RAWINPUTHEADER)
     )
     buf = create_string_buffer(pcbSize.value)
     GetRawInputData(
         lParam, RID_INPUT, buf, byref(pcbSize), sizeof(RAWINPUTHEADER)
     )
     pRawInput = cast(buf, POINTER(RAWINPUT))
     keyboard = pRawInput.contents.data.keyboard
     if keyboard.VKey == 0xFF:
         eg.eventThread.Call(eg.Print, "0xFF")
         return 0
      #print "Scan code:", keyboard.MakeCode
     info = ""
     mTime = time.clock()
     if keyboard.Message == WM_KEYDOWN:
         transition = "KEYDOWN"
     elif keyboard.Message == WM_KEYUP:
         transition = "KEYUP"
     else:
         transition = " %d" % keyboard.Message
     info = "%f " % mTime
     info += "RawI %s: %s(%d), " % (
         transition,
         VK_KEYS[keyboard.VKey],
         keyboard.VKey
     )
     if GetAsyncKeyState(162): #LCtrl
         info += "LCtrl "
     if GetAsyncKeyState(163): #RCtrl
         info += "RCtrl "
     info += "Scan: %d, " % keyboard.MakeCode
     info += "Extra: %d, " % keyboard.ExtraInformation
     info += "Device: %r, " % pRawInput.contents.header.hDevice
     #print "Flags:", keyboard.Flags
     rawKeyboardData = RawKeyboardData(
         keyboard.VKey,
         pRawInput.contents.header.hDevice,
         keyboard.Message in (WM_KEYDOWN, WM_SYSKEYDOWN),
         time.clock()
     )
     self.buf.append(rawKeyboardData)
     eg.eventThread.Call(eg.Print, info)
     if GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT:
         return DefWindowProc(hwnd, mesg, wParam, lParam)
     return 0