-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclick_button.py
More file actions
44 lines (36 loc) · 1.31 KB
/
click_button.py
File metadata and controls
44 lines (36 loc) · 1.31 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
import pyautogui
import time
def click_center_of_box(b):
"""
Click the center of the given box parameters
b: {'x': x_pos, 'y': y_pos, 'w': width, 'h': height}
"""
try:
if not b or 'x' not in b or 'y' not in b or 'w' not in b or 'h' not in b:
raise ValueError("Geçersiz kutu parametreleri")
cx = b['x'] + b['w'] // 2
cy = b['y'] + b['h'] // 2
pyautogui.moveTo(cx, cy, duration=0.15)
time.sleep(0.1)
pyautogui.click()
time.sleep(0.2)
print(f"✅ Click successful: ({cx}, {cy})")
except Exception as e:
print(f"❌ Click error: {e}")
def double_click_center_of_box(b):
"""
Double-click the center of the given box parameters
b: {'x': x_pos, 'y': y_pos, 'w': width, 'h': height}
"""
try:
if not b or 'x' not in b or 'y' not in b or 'w' not in b or 'h' not in b:
raise ValueError("Geçersiz kutu parametreleri")
cx = b['x'] + b['w'] // 2
cy = b['y'] + b['h'] // 2
pyautogui.moveTo(cx, cy, duration=0.15)
time.sleep(0.1)
pyautogui.click(clicks=2, interval=0.01)
time.sleep(0.2)
print(f"✅ Double-click successful: ({cx}, {cy})")
except Exception as e:
print(f"❌ Double-click error: {e}")