12345678910111213141516171819202122 |
- from pynput.mouse import Controller, Button
- import json
- mouseController = Controller()
- def handleMessage(properties, body):
- jsonObject = json.loads(body)
- if jsonObject.function == 0:
- on_click(jsonObject.x, jsonObject.y, jsonObject.button, jsonObject.pressed)
- else:
- on_scroll(jsonObject.x, jsonObject.y, jsonObject.dx, jsonObject.dy)
- return
- def on_click(x, y, button, pressed):
- mouseController.click(x, y, button, 1)
- def on_scroll(x, y, dx, dy):
- mouseController.position = (x, y)
- mouseController.scroll(dx, dy)
|