queueFunc.py 561 B

12345678910111213141516171819202122
  1. from pynput.mouse import Controller, Button
  2. import json
  3. mouseController = Controller()
  4. def handleMessage(properties, body):
  5. jsonObject = json.loads(body)
  6. if jsonObject.function == 0:
  7. on_click(jsonObject.x, jsonObject.y, jsonObject.button, jsonObject.pressed)
  8. else:
  9. on_scroll(jsonObject.x, jsonObject.y, jsonObject.dx, jsonObject.dy)
  10. return
  11. def on_click(x, y, button, pressed):
  12. mouseController.click(x, y, button, 1)
  13. def on_scroll(x, y, dx, dy):
  14. mouseController.position = (x, y)
  15. mouseController.scroll(dx, dy)