-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecutable.py
356 lines (307 loc) · 14 KB
/
executable.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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
import logging, time, os, sys, datetime
import tkinter as tk
from tkinter import filedialog,simpledialog
import os, sys
import subprocess, pyautogui, webbrowser, wmi
from win10toast import ToastNotifier
import psutil
from tldextract import extract
def checkIfProcessRunning(processName):
'''
Check if there is any running process that contains the given name processName.
'''
#Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False
# ~ 35 secunde pana la lansarea Steam completa
def launchGame():
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
if(os.path.exists(f'logs\{date_now}.log')):
print("File exist.")
else:
fp = open(f'{date_now}.log', 'w+')
fp.close()
print("File doesn't exist.")
if(os.path.exists(f'logs\{date_now}.log')):
LOG_FILENAME = f'logs\{date_now}.log'
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Start running Script")
else:
print("Close script.")
sys.exit()
logging.info("Start running Don't Starve Together")
subprocess.run("start steam://run/322330", shell=True)
logging.info("Wait 60 seconds")
time.sleep(60)
logging.info("Finish running Don't Starve Together")
time.sleep(1)
pyautogui.moveTo(960, 555, duration = 1)
logging.info("Move mouse in position x = 1164, y = 555 for open first part of the gift")
pyautogui.click(960, 555)
logging.info("Click mouse in position x = 960, y = 555 for open first part of the gift")
time.sleep(3)
pyautogui.moveTo(871, 728, duration = 1)
logging.info("Move mouse in position x = 871, y = 728 for open second part of the gift")
pyautogui.click(871, 728)
logging.info("Click mouse in position x = 871, y = 728 for open first part of the gift")
pyautogui.moveTo(183, 870, duration = 1)
logging.info("Move mouse in position x = 183, y = 870 for QUIT Button")
pyautogui.click(183, 870)
time.sleep(1)
pyautogui.click(183, 870)
logging.info("Click mouse in position x = 183, y = 870 for QUIT Button")
time.sleep(2)
pyautogui.click(794, 621)
logging.info("Click mouse around position x = 794, y = 621 for YES Button")
time.sleep(1)
pyautogui.moveTo(792, 621, duration = 1)
logging.info("Move mouse around position x = 794, y = 621 for YES Button")
pyautogui.click(792, 621)
logging.info("Click mouse in position x = 794, y = 621 for YES Button")
time.sleep(1)
logging.info("Don't Starve Together closed")
toast = ToastNotifier()
toast.show_toast(
f"Everything done",
f"{date_now}",
duration = 2,
threaded = True,
)
customUrlConfigPath = 'configs/customUrl.txt'
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
log_path = f"logs\{date_now}.log"
LOG_FILENAME = log_path
if(os.stat(customUrlConfigPath).st_size == 0):
configFile = open(customUrlConfigPath,"w+")
toast = ToastNotifier()
toast.show_toast(
f"Input Custom URL",
f"Insert Custom URL",
duration = 5,
threaded = True,
)
USER_INP = simpledialog.askstring(title="Custom URL", prompt="Insert custom URL:")
if(USER_INP == '' and os.stat(customUrlConfigPath).st_size == 0):
USER_INP = 'https://axbecher.com/'
inputURL = USER_INP
else:
inputURL = USER_INP
configFile.write(inputURL)
configFile.close()
customUrlOpen = open(customUrlConfigPath,"r+")
customUrlPath = customUrlOpen.readline()
tsd, td, tsu = extract(customUrlPath)
extractName = td
configFile = open(customUrlConfigPath,"w+") #open config file for process
configFile.write(customUrlPath) #write new value in customUrlConfigPath
configFile.close()
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
format_string = '%(levelname)s: %(asctime)s > %(message)s;' # Log file format
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string) #logConfig
logging.info("Custom URL not found, need to update it") #logMessage
else:
customUrlOpen = open(customUrlConfigPath,"r+")
customUrlPath = customUrlOpen.readline()
tsd, td, tsu = extract(customUrlPath) # prints abc, hostname, com
extractName = td # will prints as hostname.com
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Custom URL found, it is: "+customUrlPath)
webbrowser.open(customUrlPath, new=2)
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 300, height = 220)
canvas1.pack()
f = wmi.WMI()
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
log_path = f"logs\{date_now}.log"
LOG_FILENAME = log_path
if(os.path.exists(log_path)):
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Verified, log file exists.")
toast = ToastNotifier()
toast.show_toast(
f"File exist, abort.",
f"Log file found for {date_now}",
duration = 4,
threaded = True,
)
else:
fp = open(log_path, 'w+')
fp.close()
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Verified failed, create log file")
def LansareJoc():
customUrlConfigPath = 'configs/customUrl.txt'
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
log_path = f"logs\{date_now}.log"
LOG_FILENAME = log_path
if(os.stat(customUrlConfigPath).st_size == 0):
configFile = open(customUrlConfigPath,"w+")
toast = ToastNotifier()
toast.show_toast(
f"Input Custom URL",
f"Insert Custom URL",
duration = 5,
threaded = True,
)
USER_INP = simpledialog.askstring(title="Custom URL", prompt="Insert custom URL:")
if(USER_INP == '' and os.stat(customUrlConfigPath).st_size == 0):
USER_INP = 'https://axbecher.com/'
inputURL = USER_INP
else:
inputURL = USER_INP
configFile.write(inputURL)
configFile.close()
customUrlOpen = open(customUrlConfigPath,"r+")
customUrlPath = customUrlOpen.readline()
tsd, td, tsu = extract(customUrlPath)
extractName = td
configFile = open(customUrlConfigPath,"w+") #open config file for process
configFile.write(customUrlPath) #write new value in customUrlConfigPath
configFile.close()
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
format_string = '%(levelname)s: %(asctime)s > %(message)s;' # Log file format
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string) #logConfig
logging.info("Custom URL not found, need to update it") #logMessage
else:
customUrlOpen = open(customUrlConfigPath,"r+")
customUrlPath = customUrlOpen.readline()
tsd, td, tsu = extract(customUrlPath) # prints abc, hostname, com
extractName = td # will prints as hostname.com
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Custom URL found, it is: "+customUrlPath)
steamConfigPath = "configs/steamConfig.txt"
if(os.stat(steamConfigPath).st_size == 0):
configFile = open(steamConfigPath,"w+")
toast = ToastNotifier()
toast.show_toast(
f"Steam Location",
f"Select steam.exe",
duration = 5,
threaded = True,
)
steamExe = filedialog.askopenfilename()
configFile.write(steamExe)
configFile.close()
steamExeLoc = open(steamConfigPath,"r+")
steamPath = steamExeLoc.readline()
new_steamPath = steamPath.replace( '/', '\\' )
configFile = open(steamConfigPath,"w+")
configFile.write(new_steamPath)
configFile.close()
steamLocation = new_steamPath
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Steam Location not found, need to update it")
else:
steamExeLoc = open(steamConfigPath,"r+")
steamPath = steamExeLoc.readline()
new_steamPath = steamPath.replace( '/', '\\' )
configFile = open(steamConfigPath,"w+")
configFile.write(new_steamPath)
configFile.close()
steamLocation = new_steamPath
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Steam Location found")
if checkIfProcessRunning('steam.exe'):
canvas1.pack()
time.sleep(1)
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Steam verified passed, launch script..")
launchGame()
sys.exit()
else:
time.sleep(1)
os.startfile(steamLocation)
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Steam verified failed, locate and launch Steam..")
time.sleep(12)
launchGame()
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Steam verified passed, launch script..")
canvas1.pack()
sys.exit()
def HelpMe():
readmeLocation = "readme.txt"
os.startfile(readmeLocation)
def LogsLocation():
logsLocation = "logs"
os.startfile(logsLocation)
def Habitica():
webbrowser.open(customUrlPath, new=2)
customUrlConfigPath = 'configs/customUrl.txt'
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
log_path = f"logs\{date_now}.log"
LOG_FILENAME = log_path
if(os.stat(customUrlConfigPath).st_size == 0):
configFile = open(customUrlConfigPath,"w+")
toast = ToastNotifier()
toast.show_toast(
f"Input Custom URL",
f"Insert Custom URL",
duration = 5,
threaded = True,
)
USER_INP = simpledialog.askstring(title="Custom URL", prompt="Insert custom URL:")
if(USER_INP == '' and os.stat(customUrlConfigPath).st_size == 0):
USER_INP = 'https://axbecher.com/'
inputURL = USER_INP
else:
inputURL = USER_INP
configFile.write(inputURL)
configFile.close()
customUrlOpen = open(customUrlConfigPath,"r+")
customUrlPath = customUrlOpen.readline()
tsd, td, tsu = extract(customUrlPath)
extractName = td
configFile = open(customUrlConfigPath,"w+") #open config file for process
configFile.write(customUrlPath) #write new value in customUrlConfigPath
configFile.close()
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
format_string = '%(levelname)s: %(asctime)s > %(message)s;' # Log file format
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string) #logConfig
logging.info("Custom URL not found, need to update it") #logMessage
else:
customUrlOpen = open(customUrlConfigPath,"r+")
customUrlPath = customUrlOpen.readline()
tsd, td, tsu = extract(customUrlPath) # prints abc, hostname, com
extractName = td # will prints as hostname.com
date_now = datetime.datetime.now().strftime('%d_%m_%Y')
format_string = '%(levelname)s: %(asctime)s > %(message)s;'
LOG_FILENAME = log_path
logging.basicConfig(level=logging.DEBUG, filename=LOG_FILENAME, format=format_string)
logging.info("Custom URL found, it is: "+customUrlPath)
debugInfo = "(!) Welcome."
button1 = tk.Button (root, text="1. START",command=LansareJoc,bg='brown',fg='white')
button2 = tk.Button (root, text="2. HELP",command=HelpMe,bg='grey',fg='black')
button3 = tk.Button (root, text="3. "+extractName.upper()+"",command=Habitica,bg='purple',fg='white')
button4 = tk.Button (root, text="4. LOGS",command=LogsLocation,bg='grey',fg='white')
canvas1.create_window(150, 30, window=button1) #DontStarveTogether
canvas1.create_window(150, 70, window=button2) #Help
canvas1.create_window(150, 110, window=button3) #Habitica
canvas1.create_window(150, 150, window=button4) #Habitica
root.resizable(False, False)
root.mainloop()