Ponto0n

Change resolution

5 posts in this topic

#1 ·  Posted (edited)

Hi all,

I found a script on the forums here that would do exactly what I need it to. unfortunately it doesn't work with my resolution. the script saves current resolution, changes to a different resolution, runs a script and then changes it back to the original resolution. my problem is that it won't switch to back to the original resolution if it is a certain size, IE: 1366x768 or 1600x900. I'm really new to scripting and don't have any idea why it would work with certain resolutions and not other. here is the script that I found at on this post. I tried posting in that thread, but I'm guessing since its so old no one saw it and the original author hasn't been active for years. I'm running win7 64bit if that matters. any help would be greatly appreciated.

;~ ;................................................................................................
;~ ;................................................................................................
; Save screen resolution
IniWrite("RESsave.ini","Width","Default",@DesktopWidth)
IniWrite("RESsave.ini","Height","Default",@DesktopHeight)
IniWrite("RESsave.ini","Depth","Default",@DesktopDepth)
IniWrite("RESsave.ini","Refresh","Default",@DesktopRefresh)
;~ ;................................................................................................
;~ ;................................................................................................
; Define screen resolution
$Width = 1024
$Height = 768
$BitsPerPixel = 32
$RefreshRate = 60
; Define and set resolution
_ChangeScreenRes(1024,768,32,60)
;~ ;................................................................................................
;~ ;................................................................................................
;~ ;................................................................................................
;~ ;................................................................................................
;ADD YOUR SCRIPT HERE

Run("C:\User Config Script\word.au3")

;~ ;................................................................................................
;~ ;................................................................................................
;~ ;................................................................................................
;~ ;................................................................................................
;~ ;REVERTING BACK TO PREVIOUSE SCREEN RESSOLUTION
$DRW = IniRead("RESsave.ini","Width","Default",@DesktopWidth)
$DRH = IniRead("RESsave.ini","Height","Default",@DesktopHeight)
$DD = IniRead("RESsave.ini","Depth","Default",@DesktopDepth)
$DR = IniRead("RESsave.ini","Refresh","Default",@DesktopRefresh)
; Define and set resolution
_ChangeScreenRes($DRW,$DRH,$DD,$DR)
;~ ;................................................................................................
;~ ;................................................................................................
   Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh)
      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
         If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting
         If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting
         If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting
         If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting
      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
         SetError(1)
         Return $B
         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, $i_Width, 2)
         DllStructSetData($DEVMODE, 4, $i_Height, 3)
         DllStructSetData($DEVMODE, 4, $i_BitsPP, 1)
         DllStructSetData($DEVMODE, 4, $i_RefreshRate, 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", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width)
            $DEVMODE = ""
            Return 1
            Case Else
            $DEVMODE = ""
            SetError(1)
            Return $B
            EndSelect

         EndIf
EndFunc

 

Edited by Ponto0n

Share this post


Link to post
Share on other sites



I use a script with the built QRes.exe that works well for me!

 

_ChangeEscreenRes(1366, 768)
_ChangeEscreenRes(1600, 900)


func _ChangeEscreenRes($comp = 640, $larg = 480, $bits = 32, $hertz = 60)
ShellExecute(_QRes(true), "/x " & $comp & " /y " & $larg & " /c:" & $bits & " r:" & $hertz,@ScriptDir)
endfunc

Func _QRes( $lToSave = False, $sPath = @TempDir, $lExecute = False )
    Local $hFileHwnd, $bData, $sFileName = $sPath & "\QRes.exe"

    ; Original: D:\JukeBel\Includes2\QRes.exe
    $bData = "5rsATVqQAAMAAACCBAAw//8AALgAOC0BEEAEOBkw0ABwDh8Aug4AtAnNIbgAAUzNIVRoaXMAIHByb2dyYW0AIGNhbm5vdCAAYmUgcnVuIGkAbiBET1MgbW+AZGUuDQ0KJASwAIMR1wPHcLlQQQUDRGy3UMYADy8Qb71QxQIXuFDZQQAHpW+qUM4ABy8Qb7NQywAHUmljDmgBMwRGBgZQRQAAAEwBAQBI/vo+AQUU4AAPAQsBBuUDDhADBkgbAAcBC4IHe4B2gQMCg4OBEIGHgQMARiCAAoAL9hABgpMAfgAAFIEVhgOCCAIVAQKwcBwAAHiGBkgEgDmEQRgnLmRhdGGAD4r+DwACgU+BAYBbgAYGAYByZsCJB4EFah7AK8AAjAvAAMEDUMQB0h0AAGrEwAC4wACswADBBqoFwAb4wAAIHwAAfFXAAGjAALTAA8rAANJVwADgwADowABWwAUU1cAAKMAAOMAASMAAwQ+qGMAG8sAS/sAAJ"
    $bData &= "MACDizAAMEF2QBFcnJvAHI6ICVzCgAAiiCAAQlCAgAACYMEMAAlcy5ABsAG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HH4Xdl6P91END/FUTwAf8lSAVSADRQAGgAAAMA4UAAAQDoEzAJkAIAdkTDzAIA/yU8cgI4b1AAsAEvABwBQLDDJQHkQbAAGBAAAJQ4AURVMMVsMAE4OAFgMAEQVTABKDgBnDABADABVPU4Ab4wASwwASwH4gB/0pNTAn/SAAB/0gAAf9I8AAB/0jMFf9JzAQIDAmxAu2NweUEAACT5ArIAYXSwAHQBMEdldFbAlTDBAACEygDQAENv"
    $bData &= "bW1gyQBMaW5lQQBLRQBSTkVMMzIuZABsbAAArAJ3cwBwcmludGZBAAAbAGyxAENoYW5nZURpAHNwbGF5U2V0AHRpbmdzQQAAAAMCUmVsZWFzAGVEQwD9AEdlAnQAHMUARW51bQEPrFVTRVIzMi6AZGxsAAAlAQFWAGV2aWNlQ2FwIHMAR0RJBDRbAQBSZWdDbG9zZSBLZXkAewEaUXUAZXJ5VmFsdWUURXgAc3IBE09wZQZuACABEEFEVkFQAQU+AJ4CcHJpbgB0ZgAAmQJtZQBtc2V0AABNUxBWQ1JUA3nTAF8AZXhpdABIAF8AWGNwdEZpbHQgZXIASQICFABkAABfX3BfX19pAG5pdGVudgBYAQAPZ2V0bWFpboBhcmdzAA8BAg0xABltAIOADQAvdXMAZXJtYXRoZXIAcgAAnQBfYWQAanVzdF9mZGkwdgAAaoARgCdjbwBtbW9kZQAAbzWDB2aDBoGABoAgX2FAcHBfdHlwgA/KQ"
    $bData &= "YFOY2VwdF8AuGQAbGVyMwAAtwAAX2NvbnRyb2wIZnAAdAA="

    If $lToSave Then
        $hFileHwnd = FileOpen($sFileName, 10)
        If @error Then Return SetError(1, 0, 0)
        FileWrite($hFileHwnd, __QRes(__QResB64($bData)))
        FileClose($hFileHwnd)
        If $lExecute Then
            RunWait($sFileName, "")
            FileDelete($sFileName)
            Return 1
        EndIf
        If FileExists($sFileName) Then Return $sFileName
    Else
        Return __QRes(__QResB64($bData))
    EndIf

    Return SetError(1, 0, 0)
EndFunc   ;==>_QRes
Func __QResB64($sInput)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", 0, _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(1, 0, "") ; error calculating the length of the buffer needed
    EndIf
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _
            "str", $sInput, _
            "int", 0, _
            "int", 1, _
            "ptr", DllStructGetPtr($a), _
            "ptr", DllStructGetPtr($struct, 1), _
            "ptr", 0, _
            "ptr", 0)
    If @error Or Not $a_Call[0] Then
        Return SetError(2, 0, ""); error decoding
    EndIf
    Return DllStructGetData($a, 1)
EndFunc   ;==>__QResB64
Func __QRes($bBinary)
    $bBinary = Binary($bBinary)
    Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]")
    DllStructSetData($tInput, 1, $bBinary)
    Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer
    Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _
            "ushort", 2, _
            "ptr", DllStructGetPtr($tBuffer), _
            "dword", DllStructGetSize($tBuffer), _
            "ptr", DllStructGetPtr($tInput), _
            "dword", DllStructGetSize($tInput), _
            "dword*", 0)

    If @error Or $a_Call[0] Then
        Return SetError(1, 0, "") ; error decompressing
    EndIf

    Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer))

    Return SetError(0, 0, DllStructGetData($tOutput, 1))
EndFunc   ;==>__QRes

 

Share this post


Link to post
Share on other sites

your script is great! thank you so much! I wish I knew more about this stuff. I need to take a class or something...

Share this post


Link to post
Share on other sites

@Ponto0n think of this forum as a giant classroom, with thousands of teachers (who are also students)! Corniness aside, there isn't a better place to learn AutoIt. :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

@Ponto0n think of this forum as a giant classroom, with thousands of teachers (who are also students)! Corniness aside, there isn't a better place to learn AutoIt. :)

it's been very useful so far! scripting/coding just doesn't come naturally to me. I'm able to kind of piece things together and get it to work (sometimes, lol). but some of these advances scripts are just a foreign language to me!

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