5

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.

3 Answers 3

11

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I already had Chrome running. I killed the instance of Chrome I already had up, and now it works fine. Thank you for the tip on using os.path.join. You sir are a gentleman and a scholar.
1

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')

2 Comments

How to use webbrowser.get().open() and send F11?
@YumYumYum webbrowser starts the browser; it doesn't provide a way to interact with it (send keys, etc). Try to pass -fullscreen command line argument in addition to -kiosk above. Ask a separate question if it doesn't work.
1

Thanks for 'kill other instances' tip, solved my problem :) I use the following method :

import os
os.system('taskkill /im chrome.exe')
os.system('start chrome "https://www.youtube.com/feed/music" --kiosk')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.