forked from Brunost90/SoE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
89 lines (70 loc) · 2.56 KB
/
main.py
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
import pyautogui
from PIL import ImageGrab
import time
#def get_pixel_color_under_mouse():
# # Get the
# # current position of the mouse cursor
# x, y = pyautogui.position()
#
# # Capture the screen and get the pixel color at the cursor position
# screenshot = ImageGrab.grab()
# pixel_color = screenshot.getpixel((x, y))
#
# # Return the RGB value of the pixel color
# return pixel_color
def get_pixel_mana():
# Capture the screen and get the pixel color at the cursor position
screenshot = ImageGrab.grab()
pixel_color = screenshot.getpixel((1822, 301))
# Return the RGB value of the pixel color
return pixel_color
#### DENNE FUNKER : TRY og except er en slags failsafe !!!!!!!####
#def eatFood():
# try:
# pyautogui.locateOnScreen('sopp.PNG', confidence=0.8)
# pyautogui.moveTo('sopp.PNG')
# pyautogui.rightClick()
# pyautogui.moveTo(3333, 475)
# except:
# Exception
def eatFood():
bilder = ['sopp.PNG', 'ham.PNG', 'meat.PNG']
for bilde in bilder:
try:
location = pyautogui.locateOnScreen(bilde, confidence=0.8)
if location is not None:
# Hvis bildet ble funnet, kan du utføre ønskede handlinger
pyautogui.moveTo(location)
pyautogui.rightClick()
pyautogui.moveTo(3333, 475)
except Exception as e:
print(f'Feil oppstod: {e}')
#def print_mouse_position_for_5_seconds():
# end_time = time.time() + 5 # Run for 5 seconds from the current time
#
# while time.time() < end_time:
# x, y = pyautogui.position()
# print(f"Mouse position: ({x}, {y})")
# time.sleep(1) # Wait for 1 second before printing again
if __name__ == "__main__":
while True:
#input("Press Enter to capture pixel color...")
#print_mouse_position_for_5_seconds()
# vent 5 sekund
time.sleep(5)
# finn fargeverdi
#input("Press Enter to capture pixel color...")
#rgb_value = get_pixel_color_under_mouse()
#print(rgb_value)
# sjekk pixelverdien på mana
rgb_value = get_pixel_mana()
correct_value = (68, 68, 255)
if rgb_value == correct_value:
print("Casting Utevo lux!")
pyautogui.press('F9')
time.sleep(1)
eatFood()
else:
print("Not enough mana!")
## Hvis man bruker funksjonen her, vil at høyreklikke hele tiden###
#print(f"RGB Value: {rgb_value}")