Jump to content
Sign in to follow this  
Delai

Change resolution to the recomended

Recommended Posts

Delai

Hi i want to change the resolution display to the recomended, but it does not work. here is my script:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("WinTitleMatchMode", 2)
$Title = "Resolución"
RunWait("RunDll32.exe shell32.dll,Control_RunDLL desk.cpl")
WinActivate($Title)
sleep (500)
$Title2= WinGetTitle ( $Title,  "Pantalla" )
$Combo = ControlCommand($Title2,"","DirectUIHWND4","FindString", 'recomendado')
ControlCommand($Title2,"","DirectUIHWND4","SetCurrentSelection", $Combo)

Share this post


Link to post
Share on other sites
wakillon

Did you try this GaryFrost example ?

MsgBox(4096, "", DisplayChangeRes(1024, 768, 32, 60))

Func DisplayChangeRes($width, $height, $bpp, $freq)
    Local Const $DM_PELSWIDTH = 0x00080000
    Local Const $DM_PELSHEIGHT = 0x00100000
    Local Const $DM_BITSPERPEL = 0x00040000
    Local Const $DM_DISPLAYFREQUENCY = 0x00400000
    Local Const $CDS_TEST = 0x00000002
    Local Const $CDS_UPDATEREGISTRY = 0x00000001
    Local Const $DISP_CHANGE_RESTART = 1
    Local Const $DISP_CHANGE_SUCCESSFUL = 0
    Local Const $HWND_BROADCAST = 0xffff
    Local Const $WM_DISPLAYCHANGE = 0x007E
    Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    Local $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 = 0
                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 = 0
                Return 1
            Case Else
                $DEVMODE = 0
                Return $b
        EndSelect
    EndIf
EndFunc  ;==>DisplayChangeRes

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
Delai

It works well, but any suggest please how to change the resolution to (recomended) instead of 1024x768, i means as in the resolutions display, usually there is one recomended which i don´t know automatically until i enter. i want to select that resolution without to know which is it?

Share this post


Link to post
Share on other sites
wakillon

It works well, but any suggest please how to change the resolution to (recomended) instead of 1024x768, i means as in the resolutions display, usually there is one recomended which i don´t know automatically until i enter. i want to select that resolution without to know which is it?

See this Yashield ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.