|
@@ -1,17 +1,19 @@
|
|
|
#!/usr/bin/env python
|
|
|
+import json
|
|
|
import os
|
|
|
import signal
|
|
|
import sys
|
|
|
import time
|
|
|
|
|
|
import pika
|
|
|
+from pynput.mouse import Controller, Button
|
|
|
|
|
|
-import queueFunc
|
|
|
-import win32Test
|
|
|
+import screen
|
|
|
|
|
|
-middle_point, base_width, base_height = win32Test.arrange_windows()
|
|
|
+screenNumber = screen.arrange_slave()
|
|
|
connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.0.13', port=5672))
|
|
|
channel = connection.channel()
|
|
|
+mouseController = Controller()
|
|
|
|
|
|
|
|
|
def callback(ch, method, properties, body):
|
|
@@ -20,7 +22,7 @@ def callback(ch, method, properties, body):
|
|
|
print(time.time())
|
|
|
|
|
|
# 执行其他操作,例如记录日志、更新数据库等
|
|
|
- queueFunc.handleMessage(properties, body)
|
|
|
+ handleMessage(properties, body)
|
|
|
# 确认收到消息
|
|
|
# ch.basic_ack(delivery_tag=method.delivery_tag)
|
|
|
|
|
@@ -28,7 +30,7 @@ def callback(ch, method, properties, body):
|
|
|
def main():
|
|
|
# 定义一个交换机(exchange)
|
|
|
exchange_name = 'sync'
|
|
|
- channel.exchange_declare(exchange=exchange_name, exchange_type='fanout',durable=True)
|
|
|
+ channel.exchange_declare(exchange=exchange_name, exchange_type='fanout', durable=True)
|
|
|
|
|
|
# 定义一个队列
|
|
|
queue_name = 'hello'
|
|
@@ -53,9 +55,31 @@ def signal_handler(sig, frame):
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
+def handleMessage(properties, body):
|
|
|
+ jsonObject = json.loads(body)
|
|
|
+ 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):
|
|
|
+ for i in range(0, screenNumber):
|
|
|
+ mouseController.position = (x + i * 800, y)
|
|
|
+ if 'left' in button:
|
|
|
+ mouseController.click(Button.left, 1)
|
|
|
+ else:
|
|
|
+ mouseController.click(Button.right, 1)
|
|
|
+
|
|
|
+
|
|
|
+def on_scroll(x, y, dx, dy):
|
|
|
+ for i in range(0, screenNumber):
|
|
|
+ mouseController.position = (x +i * 800, y)
|
|
|
+ mouseController.scroll(dx, dy)
|
|
|
+
|
|
|
+
|
|
|
signal.signal(signal.SIGINT, signal_handler)
|
|
|
signal.signal(signal.SIGTERM, signal_handler)
|
|
|
-
|
|
|
if __name__ == '__main__':
|
|
|
try:
|
|
|
main()
|