-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
70 lines (51 loc) · 1.72 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
from PIL import Image
import pytesseract
import pyautogui
import os
import time
def auto_shutdown():
# This function automatically shutdowns the computer if the game from steam has finished downloading
# make the ss object
ss = pyautogui.screenshot()
# area for half the screen we need
area = (round(x / 2), 0, x, y)
ss_croped = Image.Image.crop(ss, area)
if debug is True:
ss_croped.save(directory + r"\outCroped.png")
ss.save(directory + r"\out.png")
# convert the ss object into string
string = pytesseract.image_to_string(ss_croped)
if debug is True:
print(string)
# check if the required text is in the string
if 'Play' in string:
if debug is True:
print("Program works!!")
else:
os.system('shutdown -s')
# if not call the function it self after 5 minutes
else:
time.sleep(300)
auto_shutdown()
if debug is True:
input("DEBUG COMPLETED. PRESS ENTER TO CONTINUE...")
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
# taking input the from user
x, y = input("Enter your reslotion in this format *1366x768*: ").split('x')
while True:
try:
time_in_min = float(input("Enter the estimated time (in minutes) left for the game to be downloaded: "))
break
except TypeError:
print("Wrong input. Please input an integer (in minutes):")
x = int(x) - 1
y = int(y) - 1
time_in_sec = time_in_min * 60
debug = False
if time_in_min == 696969:
debug = True
print("NOW IN DEBUG MODE!!!")
directory = input(r'Directory in which you want to save the debugged screenshots like **D:\anyfolder**: ')
time_in_sec = float(input("Enter the time in seconds: "))
time.sleep(time_in_sec)
auto_shutdown()