-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate games script basic.py
More file actions
91 lines (71 loc) · 3.29 KB
/
Update games script basic.py
File metadata and controls
91 lines (71 loc) · 3.29 KB
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
# Combined epic games and steam update games
import subprocess
import time
import psutil
valid_choices = ["steam", "epic", "all"]
while True:
direction = input("What games would you like to update? [steam, epic, all] ").lower()
if direction in valid_choices:
break
else:
print("Please type a valid input: 'steam', 'epic', or 'all'")
steam_game_dict = {
"overwach": r"C:\Program Files (x86)\Steam\steamapps\common\Overwatch\Overwatch.exe",
#"the finals": r"C:\Program Files (x86)\Steam\steamapps\common\The Finals\Discovery\Binaries\Win64\Discovery.exe", # I can't get popen to launch the finales, running the desktop link via powershell works through
"overcooked": r"D:\SteamLibrary\steamapps\common\Overcooked! 2\Overcooked2.exe",
"apex": r"C:\Program Files (x86)\Steam\steamapps\common\Apex Legends\r5apex.exe", # apex/steam prompted me to click okay to get the game to launch
"destiny": r"D:\SteamLibrary\steamapps\common\Destiny 2\destiny2.exe",
"dota2": r"D:\SteamLibrary\steamapps\common\dota 2 beta\game\bin\win64\dota2.exe"
}
epic_game_dict = {
'fortnite': r'C:\Program Files\Epic Games\Fortnite\FortniteGame\Binaries\Win64\FortniteClient-Win64-Shipping.exe',
'r6': r'C:\Program Files\Epic Games\RainbowSixSiege\RainbowSix.exe',
'rl': r'C:\Program Files\Epic Games\rocketleague\Binaries\Win64\RocketLeague.exe'
}
game_dict = {}
# Steam
if direction == "steam":
game_dict.update(steam_game_dict)
# Epic
elif direction == "epic":
game_dict.update(epic_game_dict)
# All
elif direction == "all":
game_dict.update(epic_game_dict)
game_dict.update(steam_game_dict)
print(f"{direction} directory choosen with the following games:")
for key in game_dict.keys():
print(key)
time.sleep(1.5)
# kill game with exceptions
def kill_game(game_exe, game_name):
for proc in psutil.process_iter(): # closing a game with psutil works great because if a game is updating, the exe file doesn't show up in task manager details
try:
if game_exe in proc.name(): #checks if game exe file is anywhere in proc.name, makes searching way easier
proc.kill()
print(f"{game_name} process found and has been terminated.\n")
return
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
print(f"{game_name} process not found.")
print(f"{game_name} either never launched or is queuing update :)\n")
def loop_games(game_dict):
total_games = len(game_dict)
current_game = 0
for game_name, game_path in game_dict.items():
# launch the game
subprocess.Popen(game_path)
print(f"\n{game_name} is now running.")
# Wait for game to start/load into main menu
time.sleep(60)
# get the game exe file from the game_path
game_exe = game_path.split('\\')[-1]
# Terminating the game client
kill_game(game_exe, game_name)
current_game +=1
print(f"{current_game} out of {total_games} games tested for updates\n")
# Adding another sleep statement after one game closed and before we open another one
time.sleep(7)
print(f"\nAll {total_games} games have been launched and terminated.")
time.sleep(10)
loop_games(game_dict)