Samuel
Samuel

Reputation: 420

Changing desktop screen orientation

Is there a way to change the screen orientation using python? On Ubuntu I can evoke xrandr through the os library, but what about Windows? I want to rotate the screen as a whole (as if the user pressed "ctrl+alt+down/right/left") and not just the app window. Although I'm asking for python, I can accept answers on other languages too (C++, JS, C#) as long as there is a way to do it on both, Linux and Windows (even if it is through a terminal call).

Upvotes: 0

Views: 358

Answers (1)

Ryan Comer
Ryan Comer

Reputation: 11

Rotating the screen using C# - Rotating the display programmatically?

If you wanted to use Python, you could use the ctypes library to execute C functions - https://www.journaldev.com/31907/calling-c-functions-from-python. Just follow the logic from the C# example and re-create it in Python.

The key here is that there are c functions that you need to invoke to actually rotate the screen, primarily ChangeDisplaySettingsExa - https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changedisplaysettingsexa

Upvotes: 1

Related Questions