-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnose_heal_button.py
More file actions
115 lines (94 loc) · 3.4 KB
/
Copy pathdiagnose_heal_button.py
File metadata and controls
115 lines (94 loc) · 3.4 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
"""Diagnostic tool to debug Heal button clicking."""
import pyautogui
import pygetwindow as gw
import time
from config.settings import Settings
print("=" * 70)
print("HEAL BUTTON DIAGNOSTIC TOOL")
print("=" * 70)
# Activate window
print("\n[1] Finding and activating game window...")
windows = gw.getWindowsWithTitle('Puzzles & Survival')
if not windows:
print("ERROR: Game window not found!")
exit(1)
try:
windows[0].activate()
except:
pass
time.sleep(2)
print("✓ Window activated")
# Detect Heal button
print("\n[2] Detecting Heal button on screen...")
heal = pyautogui.locateOnScreen(
Settings.IMAGE_HEAL,
confidence=Settings.HEAL_CONFIDENCE,
grayscale=True
)
if not heal:
print("✗ Heal button NOT found!")
print(f" Image: {Settings.IMAGE_HEAL}")
print(f" Confidence: {Settings.HEAL_CONFIDENCE}")
print("\nTrying lower confidence levels...")
for conf in [0.4, 0.3, 0.2]:
heal = pyautogui.locateOnScreen(
Settings.IMAGE_HEAL,
confidence=conf,
grayscale=True
)
if heal:
print(f"✓ Found at confidence {conf}: {heal}")
break
if not heal:
print("Could not find Heal button at any confidence level")
exit(1)
print(f"✓ Heal button found: {heal}")
print(f" Position: left={heal.left}, top={heal.top}")
print(f" Size: width={heal.width}, height={heal.height}")
# Calculate center
center_x = heal.left + (heal.width // 2)
center_y = heal.top + (heal.height // 2)
print(f" Center: ({center_x}, {center_y})")
# Get current mouse position
current_pos = pyautogui.position()
print(f"\n[3] Current mouse position: {current_pos}")
print("\n[4] We will:")
print(f" A. Move mouse to Heal button center: ({center_x}, {center_y})")
print(f" B. Wait 2 seconds (so you can see where it moves)")
print(f" C. Click at that position")
print(f" D. Move mouse back to {current_pos}")
input("\nPress ENTER to move mouse to Heal button center...")
# Move to button center
print(f"\nMoving mouse to ({center_x}, {center_y})...")
pyautogui.moveTo(center_x, center_y, duration=0.5)
print("✓ Mouse moved")
print("\nWaiting 2 seconds... (Check if mouse is over the correct button!)")
time.sleep(2)
# Ask user to confirm
print("\n" + "=" * 70)
response = input("Is the mouse over the CORRECT Heal button? (y/n): ").strip().lower()
if response == 'y':
print("\n✓ Position is correct!")
print("The button detection is working properly.")
print("\nNow clicking...")
pyautogui.click()
print("✓ Clicked!")
time.sleep(1)
print("\nDid the Heal button respond correctly in the game? (Check the game)")
else:
print("\n✗ Position is WRONG!")
print("\nPlease note where the mouse currently is.")
print("Then move your mouse to where the Heal button actually is.")
input("Move your mouse to the CORRECT Heal button, then press ENTER...")
correct_pos = pyautogui.position()
print(f"\nCorrect position: {correct_pos}")
print(f"Detected position was: ({center_x}, {center_y})")
print(f"Difference: x={correct_pos[0] - center_x}, y={correct_pos[1] - center_y}")
print("\nSuggested fix:")
print(f" Use hardcoded coordinates: ({correct_pos[0]}, {correct_pos[1]})")
# Move mouse back
print(f"\nMoving mouse back to original position...")
pyautogui.moveTo(current_pos[0], current_pos[1], duration=0.5)
print("\n" + "=" * 70)
print("DIAGNOSTIC COMPLETE")
print("=" * 70)