Home > OS >  How to run a web "protocol" (specifically steam://) with Python 3.9?
How to run a web "protocol" (specifically steam://) with Python 3.9?

Time:02-02

I was thinking of creating an app "organizer" with Python. This app would simply organize my apps and games. I was thinking of opening Steam games remotely. Since Steam uses steam://rungameid/(e.g. 440 for Team Fortress 2), I thought of using this code to open a game:

import webbrowser
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
webbrowser.get(chrome_path).open("steam://rungameid/440")

and it doesn't work, nor does it give an error. It merely shows the "Who's using Chrome?" portal and after you choose any account, nothing happens.

CodePudding user response:

You should not force a specific browser, you want the default protocol handler:

import webbrowser  
webbrowser.open("steam://...")

internally this should end up calling os.startfile which should call ShellExecute on Windows which is exactly what you want.

  •  Tags:  
  • Related