-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSEA.py
45 lines (37 loc) · 1.23 KB
/
CSEA.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
# Checking the Status of an External Application(game)
from time import sleep
from configparser import ConfigParser
from psutil import process_iter
from os import startfile
import sys
sys.stdout = open("outputCSEA.txt", 'w')
config = ConfigParser() # создаём объекта парсера
try:
config.read("cfg\\currectGame.ini")
gamenumber = config["CurrectGame"]["GameNumber"]
proccesname = config[gamenumber]["ProccesName"]
except BaseException:
config.read("main\\cfg\\currectGame.ini")
gamenumber = config["CurrectGame"]["GameNumber"]
proccesname = config[gamenumber]["ProccesName"]
if proccesname == "NONE.NONE":
try:
startfile(r'Nightmare.exe')
except (OSError, IOError):
startfile(r'main\Nightmare.exe')
sys.exit("указан NONE.NONE")
times = config["TimeToStartTheGameWithAMargin"]["TimeInSeconds"]
rate = config["HowManyTimesDoesItTakeMoreTimeFromTheFirstLaunch"]["rate"]
sleep(float(times) * int(rate))
# while 1:
def check():
for proc in process_iter():
if proccesname in proc.name():
return 0
return 1
while check() != 1:
sleep(float(times))
try:
startfile(r'Nightmare.exe')
except (OSError, IOError):
startfile(r'main\Nightmare.exe')