Open Display Settings or Run Dialog Box using Python

Question:

How can I open RunDialogBox or Display settings using Python?

I found a way to open Display settings using Run Dialog box (Win + R), just type in ms-settings:display.

With cmd you can type explorer.exe shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}, or with Powershell (New-Object -ComObject "Shell.Application").FileRun().

Asked By: akisha 009

||

Answers:

One simple option is to run the cmd command from Python:

import subprocess
subprocess.run(['explorer.exe', 'shell:::{2559a1f3-21d7-11d4-bdaf-00c04f60b9f0}'])

As for the Display settings, that’s also achievable in a similar way:

import subprocess
subprocess.run(['control.exe', 'desk.cpl'])
Answered By: user3738870

The ms-settings: is a URI scheme, as per Launch the Windows Settings app.

Therefore you can just use the webbrowser module, which is part of Python’s standard library, to open the Display Settings window.

import webbrowser

webbrowser.open("ms-settings:display")
Answered By: howdoicode
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.