I tried using the answer in Python check if a process is running or not to help me. However, when I tried to implement psutil into my code it did not work successfully.
I created a GUI using tkinter and I am trying to make it so as soon as the application opens, the application will be moved to the selected location. Am I using psutil incorrectly?
Here's a portion of my code:
if clicked1.get() == "Google Chrome"
os.startfile(r"{google chrome file location}")
time.sleep(4) # time.sleep to allow the application time to open
app.connect(path=r"{google chrome file location}")
app1 = app.top_window()
app1.move_window(-20, -2150) # moves application to those x and y coordinates
time.sleep(.5) # gives the application time to move before maximizing
app1.maximize()
Here's my code when I tried to implement psutil:
if clicked1.get() == "Google Chrome"
os.startfile(r"{google chrome file location}")
while True:
if "Google Chrome" in (p.name() for p in psutil.process_iter()
app.connect(path=r"{google chrome file location}")
app1 = app.top_window()
app1.move_window(-20, -2150) # moves application to those x and y coordinates
time.sleep(.5) # gives the application time to move before maximizing
app1.maximize()
break # breaks from the loop when the application is started and is moved