forked from nottherealtar/CS2AutoAccepter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccepter.py
53 lines (49 loc) · 1.43 KB
/
accepter.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
import ctypes
import pyautogui
import time
import win32api
from python_imagesearch.imagesearch import imagesearch
def get_screen_size():
"""
Get the screen size of the user's display.
"""
user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
return screensize
def click_image(image_path):
"""
Search for an image on the screen and click it once found.
"""
while True:
pos = imagesearch(image_path)
if pos[0] != -1:
win32api.SetCursorPos((pos[0], pos[1]))
pyautogui.leftClick()
break
def main():
"""
Main function to execute the script.
"""
while True:
print("Choose resolution.")
print("1.: Automatic")
print("2.: 1280x1024")
print("3.: Exit")
try:
x = int(input())
if x == 1:
screen_width, screen_height = get_screen_size()
print(f"Detected screen resolution: {screen_width}x{screen_height}")
click_image("accept19201080.png")
elif x == 2:
click_image("accept12801024.png")
elif x == 3:
exit()
else:
print("This isn't a valid option.")
time.sleep(3)
except ValueError:
print("Please enter a valid number.")
time.sleep(3)
if __name__ == "__main__":
main()