Depending on how your script is launched, focusing and maybe not necessarily working, as there may be a shell running without logging in, and it will stop when your browser session ends. But there is a whole existing thread dedicated to this problem: Calling an external command in Python
What you want to do is create a separate process or create a daemon that is launched by clicking on your browser.
cybertoast
source share