I found a "just me" script that sets the resolution but does not have the ability to rotate the screen.
How can I modify it to add this feature?
Code: Select all
ChangeDisplaySettings(cD, sW, sH, rR)
{
Static DM := {BITSPERPEL: 0x040000, PELSWIDTH: 0x080000, PELSHEIGHT: 0x100000, DISPLAYFREQUENCY: 0x400000}
;Calculate offset of DEVMODE fields:
Static size := A_IsUnicode ? 220 : 156
Static dmSize := A_IsUnicode ? 68 : 36 ; <<< has to be dmSize, not smSize
Static dmFields := dmSize + 4
Static dmBitsPerPel := A_IsUnicode ? 168 : 104
Static dmPelsWidth := dmBitsPerPel + 4
Static dmPelsHeight := dmPelsWidth + 4
Static dmDisplayFrequency := dmPelsHeight + 8
dmAddr := 0
VarSetCapacity(DEVMODE, size, 0)
NumPut(size, DEVMODE, dmSize, "UShort")
fields := 0
If (cD <> "") {
NumPut(cD, DEVMODE, dmBitsPerPel, "UInt")
fields |= DM.BITSPERPEL
}
If (sW <> "") {
NumPut(sW, DEVMODE, dmPelsWidth, "UInt")
fields |= DM.PELSWIDTH
}
If (sH <> "") {
NumPut(sH, DEVMODE, dmPelsHeight, "UInt")
fields |= DM.PELSHEIGHT
}
If (rR <> "") {
NumPut(rR, DEVMODE, dmDisplayFrequency, "UInt")
fields |= DM.DISPLAYFREQUENCY
}
If (fields > 0) {
NumPut(fields, DEVMODE, dmFields, "UInt")
dmAddr := &DEVMODE
}
Return DllCall("User32.dll\ChangeDisplaySettings", "Ptr", dmAddr, "UInt", 0, "Int")
}