Sign in to follow this  
Followers 0
langtudongnai45

Change color depth of desktop?

7 posts in this topic

#1 ·  Posted (edited)

Hi all,

I have a question: How to change color depth of desktop from 16bit to 32bit and the same?

I used  ChangeScreenRes.au3 UDF but not working on 1920x1080 resolution :(

Please help me. 

Thanks and best regards   :sweating:

Edited by langtudongnai45

Share this post


Link to post
Share on other sites



UDF link?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Try again, 404 error.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

There is a link in the code >> http://www.autoitscript.com/forum/index.php?showtopic=20121. The author explicitly states use a different UDF, hence maybe search the Forum for a better UDF.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Try this ( N.B. i have stripped some part like the orientation/GUI and added the Const into the Func )

; psandu.ro - PartyPooper - KaFu
_ChangeScreenRes(@DesktopWidth, @DesktopHeight, 16, @DesktopRefresh)
Sleep(2000)
_ChangeScreenRes(@DesktopWidth, @DesktopHeight, 32, @DesktopRefresh)

Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh)
    Local $h_DLL_user32 = DllOpen("user32.dll")
    Local Const $ENUM_CURRENT_SETTINGS = -1
    Local Const $ENUM_REGISTRY_SETTINGS = -2
    Local Const $_tag_POINTL = "long x;long y"
    Local Const $_tag_DEVMODE = "char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _
            "ushort dmDriverExtra;dword dmFields;" & $_tag_POINTL & ";dword dmDisplayOrientation;dword dmDisplayFixedOutput;" & _
            "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _
            "byte dmFormName[32];ushort LogPixels;dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _
            "dword dmDisplayFlags;dword dmDisplayFrequency"

    Local Const $DM_ORIENTATION = 0x00000001
    Local Const $DM_PAPERSIZE = 0x00000002
    Local Const $DM_PAPERLENGTH = 0x00000004
    Local Const $DM_PAPERWIDTH = 0x00000008
    Local Const $DM_SCALE = 0x00000010
    Local Const $DM_COPIES = 0x00000100
    Local Const $DM_DEFAULTSOURCE = 0x00000200
    Local Const $DM_PRINTQUALITY = 0x00000400
    Local Const $DM_POSITION = 0x00000020
    Local Const $DM_DISPLAYORIENTATION = 0x00000080
    Local Const $DM_DISPLAYFIXEDOUTPUT = 0x20000000
    Local Const $DM_COLOR = 0x00000800
    Local Const $DM_DUPLEX = 0x00001000
    Local Const $DM_YRESOLUTION = 0x00002000
    Local Const $DM_TTOPTION = 0x00004000
    Local Const $DM_COLLATE = 0x00008000
    Local Const $DM_FORMNAME = 0x00010000
    Local Const $DM_LOGPIXELS = 0x00020000
    Local Const $DM_BITSPERPEL = 0x00040000
    Local Const $DM_PELSWIDTH = 0x00080000
    Local Const $DM_PELSHEIGHT = 0x00100000
    Local Const $DM_DISPLAYFLAGS = 0x00200000
    Local Const $DM_NUP = 0x00000040
    Local Const $DM_DISPLAYFREQUENCY = 0x00400000
    Local Const $DM_ICMMETHOD = 0x00800000
    Local Const $DM_ICMINTENT = 0x01000000
    Local Const $DM_MEDIATYPE = 0x02000000
    Local Const $DM_DITHERTYPE = 0x04000000
    Local Const $DM_PANNINGWIDTH = 0x08000000
    Local Const $DM_PANNINGHEIGHT = 0x10000000
    Local Const $DM_DISPLAYQUERYORIENTATION = 0x01000000
    Local Const $CDS_TEST = 0x00000002
    Local Const $CDS_UPDATEREGISTRY = 0x00000001
    Local Const $CDS_RESET = 0x40000000
    Local Const $CDS_SET_PRIMARY = 0x00000010
    Local Const $CDS_VIDEOPARAMETERS = 0x00000020
    Local Const $CDS_ENABLE_UNSAFE_MODES = 0x00000100
    Local Const $CDS_DISABLE_UNSAFE_MODES = 0x00000200

    ; error 2 = EnumDisplaySettingsEx for $ENUM_CURRENT_SETTINGS failed
    Local Const $DISP_CHANGE_SUCCESSFUL = 0
    Local Const $DISP_CHANGE_FAILED = -1
    Local Const $DISP_CHANGE_BADMODE = -2
    Local Const $DISP_CHANGE_NOTUPDATED = -3
    Local Const $DISP_CHANGE_BADFLAGS = -4
    Local Const $DISP_CHANGE_BADPARAM = -5
    Local Const $DISP_CHANGE_BADDUALVIEW = -6
    Local Const $DISP_CHANGE_RESTART = 1

    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($_tag_DEVMODE)
    DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE))

    ; Using the dmFields flag of DM_DISPLAYORIENTATION, ChangeDisplaySettingsEx can be used to dynamically rotate the screen orientation. However, the DM_PELSWIDTH and DM_PELSHEIGHT flags cannot be used to change the screen resolution.

    Local $i_DllRet = DllCall($h_DLL_user32, "int", "EnumDisplaySettingsEx", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($DEVMODE), "dword", 0)
    If $i_DllRet[0] = 0 Then
        $i_DllRet = DllCall($h_DLL_user32, "int", "EnumDisplaySettingsEx", "ptr", 0, "dword", $ENUM_REGISTRY_SETTINGS, "ptr", DllStructGetPtr($DEVMODE), "dword", 0)
    EndIf

    #cs
        ConsoleWrite("dmDeviceName " & DllStructGetData($DEVMODE, "dmDeviceName") & @CRLF)
        ConsoleWrite("dmSpecVersion " & DllStructGetData($DEVMODE, "dmSpecVersion") & @CRLF)
        ConsoleWrite("dmDriverVersion " & DllStructGetData($DEVMODE, "dmDriverVersion") & @CRLF)
        ConsoleWrite("dmSize " & DllStructGetData($DEVMODE, "dmSize") & @CRLF)
        ConsoleWrite("dmDriverExtra " & DllStructGetData($DEVMODE, "dmDriverExtra") & @CRLF)
        ConsoleWrite("dmFields " & DllStructGetData($DEVMODE, "dmFields") & @CRLF)
        ConsoleWrite("dmPositionx " & DllStructGetData($DEVMODE, "dmPositionx") & @CRLF)
        ConsoleWrite("dmPositiony " & DllStructGetData($DEVMODE, "dmPositiony") & @CRLF)
        ConsoleWrite("- dmDisplayOrientation " & DllStructGetData($DEVMODE, "dmDisplayOrientation") & @CRLF)
        ConsoleWrite("dmDisplayFixedOutput " & DllStructGetData($DEVMODE, "dmDisplayFixedOutput") & @CRLF)
        ConsoleWrite("dmColor " & DllStructGetData($DEVMODE, "dmColor") & @CRLF)
        ConsoleWrite("dmDuplex " & DllStructGetData($DEVMODE, "dmDuplex") & @CRLF)
        ConsoleWrite("dmYResolution " & DllStructGetData($DEVMODE, "dmYResolution") & @CRLF)
        ConsoleWrite("dmTTOption " & DllStructGetData($DEVMODE, "dmTTOption") & @CRLF)
        ConsoleWrite("dmCollate " & DllStructGetData($DEVMODE, "dmCollate") & @CRLF)
        ConsoleWrite("dmFormName " & DllStructGetData($DEVMODE, "dmFormName") & @CRLF)
        ConsoleWrite("dmLogPixels " & DllStructGetData($DEVMODE, "dmLogPixels") & @CRLF)
        ConsoleWrite("dmBitsPerPel " & DllStructGetData($DEVMODE, "dmBitsPerPel") & @CRLF)
        ConsoleWrite("dmPelsWidth " & DllStructGetData($DEVMODE, "dmPelsWidth") & @CRLF)
        ConsoleWrite("dmPelsHeight " & DllStructGetData($DEVMODE, "dmPelsHeight") & @CRLF)
        ConsoleWrite("dmDisplayFlags " & DllStructGetData($DEVMODE, "dmDisplayFlags") & @CRLF)
        ConsoleWrite("dmDisplayFrequency " & DllStructGetData($DEVMODE, "dmDisplayFrequency") & @CRLF & @CRLF)
    #ce

    If @error Then
        $DEVMODE = 0
        SetError(1)
        Return 1
    Else
        $i_DllRet = $i_DllRet[0]
    EndIf

    If $i_DllRet <> 0 Then
        DllStructSetData($DEVMODE, "dmPelsWidth", $i_Width)
        DllStructSetData($DEVMODE, "dmPelsHeight", $i_Height)
        DllStructSetData($DEVMODE, "dmBitsPerPel", $i_BitsPP)
        DllStructSetData($DEVMODE, "dmDisplayFrequency", $i_RefreshRate)
        $i_DllRet = DllCall($h_DLL_user32, "int", "ChangeDisplaySettingsEx", "ptr", 0, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "int", $CDS_TEST, "ptr", 0)
        If @error Then
            $DEVMODE = 0
            SetError(2)
            Return 2
        Else
            $i_DllRet = $i_DllRet[0]
        EndIf
        Select
            Case $i_DllRet = $DISP_CHANGE_SUCCESSFUL
                $i_DllRet = DllCall($h_DLL_user32, "int", "ChangeDisplaySettingsEx", "ptr", 0, "ptr", DllStructGetPtr($DEVMODE), "hwnd", 0, "int", $CDS_UPDATEREGISTRY, "ptr", 0)
                If @error Then
                    $DEVMODE = 0
                    SetError(2)
                    Return 3
                Else
                    $i_DllRet = $i_DllRet[0]
                EndIf
                If $i_DllRet <> $DISP_CHANGE_SUCCESSFUL Then
                    $DEVMODE = 0
                    SetError($i_DllRet)
                    Return 3
                EndIf
                Return 0 ; Success !
            Case Else
                $DEVMODE = 0
                SetError($i_DllRet)
                Return 2
        EndSelect
    EndIf
    $DEVMODE = 0
    SetError(2)
    Return 1
EndFunc   ;==>_ChangeScreenRes

'?do=embed' frameborder='0' data-embedContent>>

Edited by johnmcloud
1 person likes this

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  
Followers 0