Jump to content

Changing Screen Resolution


jebus495
 Share

Recommended Posts

XP Home SP2 I believe.

I tried using a function I found HERE by psandu.ro but I can't seem to get it to work.

#include <Timers.au3>

While 1
$timer = _Timer_GetIdleTime()
If $timer > 5000 And @DesktopHeight+@DesktopWidth <> 1400 Then
    Switch MsgBox(36, "Greetings", "Would you like to change the resolution back?" & @CRLF & @DesktopHeight & @CRLF & @DesktopWidth)
        Case 6
            DisplayChangeRes(800, 600, 32, 85)
        ;Case 7

    EndSwitch
EndIf
Sleep(500)
WEnd

Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ)
$DM_PELSWIDTH = 0x00080000
$DM_PELSHEIGHT = 0x00100000
$DM_BITSPERPEL = 0x00040000
$DM_DISPLAYFREQUENCY = 0x00400000
$CDS_TEST = 0x00000002
$CDS_UPDATEREGISTRY = 0x00000001
$DISP_CHANGE_RESTART = 1
$DISP_CHANGE_SUCCESSFUL = 0
$HWND_BROADCAST = 0xffff
$WM_DISPLAYCHANGE = 0x007E
$DEVMODE = DLLStructCreate ("byte[32];int[10];byte[32];int[6]")
$B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DLLStructGetPtr ($DEVMODE))
If @error Then
$B = 0
Else
$B = $B[0]
EndIf
If $B <> 0 Then
DllStructSetData ($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
DllStructSetData ($DEVMODE, 4, $WIDTH, 2)
DllStructSetData ($DEVMODE, 4, $HEIGHT, 3)
DllStructSetData ($DEVMODE, 4, $BPP, 1)
DllStructSetData ($DEVMODE, 4, $FREQ, 5)
$B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DLLStructGetPtr ($DEVMODE), "int", $CDS_TEST)
If @error Then
    $B = -1
Else
    $B = $B[0]
EndIf
Select
Case $B = $DISP_CHANGE_RESTART
$DEVMODE = ""
Return 2
Case $B = $DISP_CHANGE_SUCCESSFUL
DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DLLStructGetPtr ($DEVMODE), "int", $CDS_UPDATEREGISTRY)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _
"int", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH)
$DEVMODE = ""
Return 1
Case Else
$DEVMODE = ""
Return $B
EndSelect
EndIf
EndFunc ;==>DisplayChangeRes

Well it does work but it puts the screen in its default orientation? Ugly black border that you need to press buttons on your monitor to fix? I don't know If I've explained that part well enough lol. Using an older monitor. The function doesn't seem to behave exactly like the real one which keeps the same when switching resolutions.

Link to comment
Share on other sites

Well, there's no magic in the call to ChangeDisplaySettings, and monitor orientation is not controlled from there. It must be a response of your monitor driver to the resolution being changed from outside the expected tools.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...