每次转动显示器时,我都必须进入设置,有什么方法可以在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()
显示开关用于选择如何将屏幕镜像到第二个屏幕
你可以使用Display64.exe然后可以使用以下代码。
import subprocess
subprocess.run(['C:\\Users\\User\\Display64.exe','/device:2','/rotate:90','/toggle'])
找到