Here is how I am trying to do it:
# Start Google Chrome
subprocess.call(["C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "--kiosk"])
If I add the --kiosk flag to the Google Chrome shortcut on my desktop, Chrome does start in kiosk mode. However, when I try this through Python, it doesn't seem to work. I've searched Google and here, but have found nothing so far. Please help.
That command works for me just fine.
Make sure you're not running another copy of Chrome. It appears that Chrome will only start in Kiosk mode if no other instances are running. If you want to make sure no other instances are running, this answer shows how you could kill them before starting a new process:
import os
import subprocess
CHROME = os.path.join('C:\\', 'Program Files (x86)', 'Google', 'Chrome', 'Application', 'chrome.exe')
os.system('taskkill /im chrome.exe')
subprocess.call([CHROME, '--kiosk'])
As a side note, it is always nice to use os.path.join
, even if your code is platform-specific at this point.
You could use raw-string literals for Windows paths:
import subprocess
chrome = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
subprocess.check_call([chrome, '--kiosk'])
Note: "\\n" == r'\n' != '\n'
. Though it doesn't make any difference in your case.
You could try to pass --new-window
option to open a new window.
If all you need is to open an url in a new Google Chrome window:
import webbrowser
webbrowser.get('google-chrome').open_new('https://example.com')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With