|
@@ -5,13 +5,17 @@ from pynput.mouse import Controller, Button
|
|
|
import asyncio
|
|
|
|
|
|
import win32Test
|
|
|
+import pika
|
|
|
+import messageClass
|
|
|
+
|
|
|
+connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
|
|
|
+channel = connection.channel()
|
|
|
+
|
|
|
+channel.exchange_declare("sync", "fanout", durable=True)
|
|
|
|
|
|
mouse_controller = Controller()
|
|
|
|
|
|
middle_point, base_width, base_height = win32Test.arrange_windows()
|
|
|
-print(middle_point)
|
|
|
-print(base_width)
|
|
|
-print(base_height)
|
|
|
|
|
|
|
|
|
def in_monitorZone():
|
|
@@ -23,7 +27,6 @@ def in_monitorZone():
|
|
|
|
|
|
|
|
|
def on_click(x, y, button, pressed):
|
|
|
-
|
|
|
# function:0
|
|
|
# x:
|
|
|
# y:
|
|
@@ -36,10 +39,8 @@ def on_click(x, y, button, pressed):
|
|
|
# dx,
|
|
|
# dy,
|
|
|
|
|
|
- print('{0} at {1}'.format(
|
|
|
- 'Pressed' if pressed else 'Released',
|
|
|
- (x, y)))
|
|
|
- print(button)
|
|
|
+ message = messageClass.ClickMessage(x, y, button).getMessage()
|
|
|
+ channel.basic_publish(exchange='sync', routing_key='', body=message)
|
|
|
# if not pressed:
|
|
|
# # Stop listener
|
|
|
# return False
|
|
@@ -54,17 +55,20 @@ async def scroll_to_next_point(middle_point, mouse_controller, dx, dy):
|
|
|
|
|
|
|
|
|
def on_scroll(x, y, dx, dy):
|
|
|
- print('Scrolled {0} at {1}'.format(
|
|
|
- 'down' if dy < 0 else 'up',
|
|
|
- (x, y)))
|
|
|
- if in_monitorZone():
|
|
|
- origin = mouse_controller.position
|
|
|
- for i in range(1, len(middle_point)):
|
|
|
- print('scrolled')
|
|
|
- mouse_controller.position = middle_point[i]
|
|
|
- mouse_controller.click(Button.right, 1)
|
|
|
- time.sleep(0.5)
|
|
|
- mouse_controller.position = origin
|
|
|
+ message = messageClass.ScrollMessage(x, y, dx, dy).getMessage()
|
|
|
+ channel.basic_publish(exchange='sync', routing_key='', body=message)
|
|
|
+
|
|
|
+ # print('Scrolled {0} at {1}'.format(
|
|
|
+ # 'down' if dy < 0 else 'up',
|
|
|
+ # (x, y)))
|
|
|
+ # if in_monitorZone():
|
|
|
+ # origin = mouse_controller.position
|
|
|
+ # for i in range(1, len(middle_point)):
|
|
|
+ # print('scrolled')
|
|
|
+ # mouse_controller.position = middle_point[i]
|
|
|
+ # mouse_controller.click(Button.right, 1)
|
|
|
+ # time.sleep(0.5)
|
|
|
+ # mouse_controller.position = origin
|
|
|
|
|
|
|
|
|
# Collect events until released
|