@@ -51,20 +51,23 @@ async def monitor_mouse_movement(client, config, starting_mouse_position):
5151 message = f"Mouse moved to `{ current_mouse_position [0 ]} `, `{ current_mouse_position [1 ]} `"
5252 last_movement_time = datetime .datetime .now ().strftime ("%d-%m-%Y %H:%M:%S" )
5353
54- screenshot = ImageGrab .grab (
55- bbox = (
56- current_mouse_position [0 ]
57- - 400 , # Adjust the X coordinate to capture around the mouse
58- current_mouse_position [1 ]
59- - 300 , # Adjust the Y coordinate to capture around the mouse
60- current_mouse_position [0 ]
61- + 400 , # Adjust the X coordinate to capture around the mouse
62- current_mouse_position [1 ]
63- + 300 , # Adjust the Y coordinate to capture around the mouse
54+ try :
55+ screenshot = ImageGrab .grab (
56+ bbox = (
57+ current_mouse_position [0 ] - 400 ,
58+ current_mouse_position [1 ] - 300 ,
59+ current_mouse_position [0 ] + 400 ,
60+ current_mouse_position [1 ] + 300 ,
61+ )
6462 )
65- )
6663
67- screenshot .save (SCREENSHOT_PATH )
64+ screenshot .save (SCREENSHOT_PATH )
65+ except OSError as e :
66+ print (f"[mouse_movement_LOG] - Error capturing screenshot: { e } " )
67+ await asyncio .sleep (5 )
68+ continue # Skip the rest of the loop iteration if there's an error
69+
70+
6871
6972 # Check if image_message is not None and attempt to delete it if it exists
7073 if image_message :
0 commit comments