import pyautogui
from pynput import mouse, keyboardpyautogui.FAILSAFE =Falseclass MouseMonitor:def __init__(self):self.mouse = mouse.Controller()self.lock = Truedef on_move(self, x, y):'''鼠标位移时回调函数'''if self.lock:print('11')pyautogui.moveTo(500, 500)self.lock = Falsedef on_click(self, x, y, button, pressed):action = "Pressed" if pressed else "Released"print(f"Mouse {action} at ({x}, {y}) with {button}")def on_scroll(self, x, y, dx, dy):print(f"Mouse scrolled at ({x}, {y}) with delta ({dx}, {dy})")def on_press(self, key):try:print(key.char)except Exception:print(key)return Truedef start_monitoring(self):l1 = mouse.Listener(on_move=self.on_move, on_click=self.on_click, on_scroll=self.on_scroll, on_press=self.on_press)l2 = keyboard.Listener(on_press=self.on_press)l1.start()l2.start()l1.join()l2.join()if __name__ == "__main__":mouse_monitor = MouseMonitor()mouse_monitor.start_monitoring()