有没有办法在 Windows 上使用 Python 更改显示器方向?

问题描述 投票:0回答:1

每次转动显示器时,我都必须进入设置,有什么方法可以在Python中自动更改屏幕方向吗?我使用的是 Windows 10。

我尝试过使用快捷方式(ctrl alt right),但这不起作用。

这是 ChatGPT 提出的:

from screeninfo import get_monitors
import subprocess

def rotate_screen():
    # Get information about all monitors
    monitors = list(get_monitors())

    # Assuming the second monitor is the one you want to rotate
    if len(monitors) > 1:
        subprocess.run(["DisplaySwitch.exe", "/rotate:90"])

if __name__ == "__main__":
    rotate_screen()

显示开关用于选择如何将屏幕镜像到第二个屏幕

python windows multiple-monitors
1个回答
0
投票

你可以使用Display64.exe然后可以使用以下代码。

import subprocess
subprocess.run(['C:\\Users\\User\\Display64.exe','/device:2','/rotate:90','/toggle'])

更多信息可以在这里这里

找到
© www.soinside.com 2019 - 2024. All rights reserved.