'How do I detect if a Window gets closed?
Ok I opened a .mp4 using
import os
os.startfile('test.mp4')
How can I detect when the window (of the default Windows app used to show videos) gets closed to run the rest of the code?
Solution 1:[1]
You can't do it with startfile.
From Python documentation:
There is no option to wait for the application to close, and no way to retrieve the application’s exit status
You would need to use the subprocess module instead:
import subprocess
subprocess.run(['start', 'test.mp4'])
# do other stuff
This command will not exit until the program you ran is closed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lev M. |
