12345678910111213141516171819202122232425262728293031 |
- from pynput.mouse import Controller, Button
- import json
- import time
- mouseController = Controller()
- def handleMessage(properties, body):
- jsonObject = json.loads(body)
- print(jsonObject)
- print(time.time())
- if jsonObject['function'] == 0:
- on_click(jsonObject['x'], jsonObject['y'], jsonObject['button'])
- else:
- on_scroll(jsonObject['x'], jsonObject['y'], jsonObject['dx'], jsonObject['dy'])
- def on_click(x, y, button):
- mouseController.position = (x, y)
- if 'left' in button:
- print('w')
- mouseController.click(Button.left, 1)
- else:
- print('2')
- mouseController.click(Button.right, 1)
- def on_scroll(x, y, dx, dy):
- mouseController.position = (x, y)
- mouseController.scroll(dx, dy)
|