I wanna make a python script to open a certain app whenever I am not playing any video games any ideas how to do that??? your help is appreciated
CodePudding user response:
You can achieve this fairly simply by doing:
import os
os.chdir("C:/game/location")#enter where the game's .exe file is located
os.system("game.exe")#enter the exe filename
CodePudding user response:
To open the certain app, install psutil with pip install psutil
.
Then:
import psutil
games_list = ["minecraft.exe"] #game exe file
for app in psutil.process_iter():
if app.name() in games_list:
print("Game {app.name()} open.") #output - "Game minecraft.exe open."