Remote-Desktop-App/structures/handling_recieve.py

61 lines
1.6 KiB
Python

import pyautogui
from screeninfo import get_monitors
[screenWidth, screenHeight] = [
[screen.width, screen.height] for screen in get_monitors() if screen.is_primary
][0]
class MouseKeyboardHandler:
@staticmethod
def mouse(event_type, *args):
if event_type == "CLICK":
if args[0] == "Right":
pyautogui.click(button='right')
else:
pyautogui.click(button='left')
elif event_type == "SCROLL":
if args[0] > 0:
pyautogui.scroll(200)
else:
pyautogui.scroll(-200)
elif event_type == "MOVE":
x, y = args[:2]
physicalX = x * screenWidth
physicalY = y * screenHeight
pyautogui.moveTo(physicalX, physicalY, duration=0.1)
@staticmethod
def keyboard(string):
special_keys = {
"enter": "enter",
"backspace": "backspace",
"space": "space",
"esc": "esc",
"ctrl": "ctrl",
"alt": "alt",
"shift": "shift",
"up": "up",
"down": "down",
"left": "left",
"right": "right",
"f1": "f1",
"f2": "f2",
"f3": "f3",
"f4": "f4",
"f5": "f5",
"f6": "f6",
"f7": "f7",
"f8": "f8",
"f9": "f9",
"f10": "f10",
"f11": "f11",
"f12": "f12",
"f13": "f13",
}
if string in special_keys:
pyautogui.press(special_keys[string])
else:
pyautogui.typewrite(string)