-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
46 lines (37 loc) · 1.24 KB
/
Copy pathutils.py
File metadata and controls
46 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import time
import pyautogui
from typing import Tuple, Optional
def perform_click(x: int, y: int, interval: float = 0.0) -> None:
"""Executes a mouse click at the specified coordinates.
Args:
x: Horizontal coordinate.
y: Vertical coordinate.
interval: Seconds to wait after clicking.
"""
pyautogui.click(x, y)
if interval > 0:
time.sleep(interval)
def get_mouse_position() -> Tuple[int, int]:
"""Retrieves the current mouse cursor location.
Returns:
A tuple containing (x, y) coordinates.
"""
return pyautogui.position()
def safe_move(x: int, y: int, duration: float = 0.25) -> None:
"""Smoothly moves the mouse to target coordinates.
Args:
x: Destination x coordinate.
y: Destination y coordinate.
duration: Time taken to reach the destination.
"""
pyautogui.moveTo(x, y, duration=duration)
def validate_screen_bounds(x: int, y: int) -> bool:
"""Checks if coordinates are within primary monitor limits.
Args:
x: Horizontal coordinate.
y: Vertical coordinate.
Returns:
True if coordinates are visible on screen.
"""
width, height = pyautogui.size()
return 0 <= x <= width and 0 <= y <= height