python监听鼠标和键盘
2017-07-09 16:20
288 查看
import PyHook3 def OnMouseEvent(event): print('MessageName:',event.MessageName) print('Message:',event.Message) print('Time:',event.Time) print('Window:',event.Window) print('WindowName:',event.WindowName) print('Position:',event.Position) print('Wheel:',event.Wheel) print('Injected:',event.Injected) print('---') # return True to pass the event to other handlers # return False to stop the event from propagating return True def OnKeyboardEvent(event): print('MessageName:',event.MessageName) print('Message:',event.Message) print('Time:',event.Time) print('Window:',event.Window) print('WindowName:',event.WindowName) print('Ascii:', event.Ascii, chr(event.Ascii)) print('Key:', event.Key) print('KeyID:', event.KeyID) print('ScanCode:', event.ScanCode) print('Extended:', event.Extended) print('Injected:', event.Injected) print('Alt', event.Alt) print('Transition', event.Transition) print('---') # return True to pass the event to other handlers # return False to stop the event from propagating return True # create the hook mananger hm = PyHook3.HookManager() # register two callbacks hm.MouseAllButtonsDown = OnMouseEvent hm.KeyDown = OnKeyboardEvent # hook into the mouse and keyboard events hm.HookMouse() hm.HookKeyboard() if __name__ == '__main__': import pythoncom pythoncom.PumpMessages()
相关文章推荐
- Python中使用PyHook监听鼠标和键盘事件实例
- 用Python监听鼠标和键盘事件
- 用Python监听鼠标和键盘事件
- 用Python监听鼠标和键盘事件
- Python利用pyHook实现监听用户鼠标与键盘事件
- Python利用pyHook实现监听用户鼠标与键盘事件
- Python 键盘鼠标监听
- Python中使用PyHook监听鼠标和键盘事件实例
- Python 键盘鼠标监听
- python 监听鼠标键盘事件
- Python2.7: 使用Pyhook模块监听鼠标键盘事件-获取坐标
- 用Python监听鼠标和键盘事件
- 用Python监听鼠标和键盘事件(转载)
- Python监听鼠标和键盘
- python 监听键盘鼠标
- Python利用pyHook实现监听用户鼠标与键盘事件
- Python中使用PyHook监听鼠标和键盘事件实例
- python2 监听模拟鼠标键盘事件
- 用Python监听鼠标和键盘事件
- Python实现鼠标、键盘事件的记录