I'm trying to adjust the "display orientation" setting in Windows 11.
Possible values in Settings > Display > Display Orientation are "Landscape", "Portrait", "Landscape (flipped)", "Portrait (flipped)". (0°, 90°, 180°, 270°)
I can't use the system hotkeys (CTRL+ALT+ARROW KEY) because those no longer exist natively in Windows 11.
When searching the forum, I found an interesting hotkey script from user @malcev here:
viewtopic.php?f=76&t=87453&hilit=ChangeDisplaySettingsW
Code: Select all
VarSetCapacity(DEVMODE, 220, 0)
NumPut(220, DEVMODE, 68, "short") ; dmSize
DllCall("EnumDisplaySettingsW", "ptr", 0, "int", -1, "ptr", &DEVMODE)
width := NumGet(DEVMODE, 172, "uint")
height := NumGet(DEVMODE, 176, "uint")
NumPut(width, DEVMODE, 176, "int")
NumPut(height, DEVMODE, 172, "int")
NumPut(DMDO_90 := 1, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
sleep 2000
NumPut(width, DEVMODE, 172, "int")
NumPut(height, DEVMODE, 176, "int")
NumPut(DMDO_180 := 2, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
sleep 2000
NumPut(width, DEVMODE, 176, "int")
NumPut(height, DEVMODE, 172, "int")
NumPut(DMDO_270 := 3, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
sleep 2000
NumPut(width, DEVMODE, 172, "int")
NumPut(height, DEVMODE, 176, "int")
NumPut(DMDO_DEFAULT := 0, DEVMODE, 84, "int") ; dmDisplayOrientation
DllCall("ChangeDisplaySettingsW", "ptr", &DEVMODE, "uint", 0)
Can someone please help?
Many thanks in advance!
Pieter