Sign in to follow this  
Followers 0
VelvetElvis

Change XP desktop color

7 posts in this topic

I have a need to change my XP desktop color via code. Should be dead simple, but I've spent several hours trying to solve this. I'd be happy if someone called me a worthless n00b and pointed out the obvious to me. :unsure:

I've tried code I dug up in the forum:

$COLOR_DESKTOP = 1
$COLOR = 0xFFFFFF
$DLL_Call = DLLCall("user32.dll","int","SetSysColors","int",1,"int_ptr",$COLOR_DESKTOP,"int_ptr",$color)

but nothing happens.

I've tried this:

RegWrite("HKEY_CURRENT_USER\Control Panel\Colors", "Background", "REG_SZ", "102 154 202")
RunWait("rundll32 user32.dll,UpdatePerUserSystemParameters")

... and nothing.

Changing the registry key

HKEY_CURRENT_USER --> Control Panel --> Colors --> Background

works on reboot, but I need to have it immediate.

I've looked at the help, including _WinAPI_SetBkColor in the help, but the code left me glassy-eyed, and doesn't appear to be what I want.

While I'm able to change the wallpaper immediately, I don't want that. I simply want to change the background color, and leave any wallpaper intact.

I munged together code to open Display Properties and make the necessary changes, but that's ugly, and I hope won't be necessary.

Hope someone can help me!

Share this post


Link to post
Share on other sites



Just a thought it might require a Restart of Explorer.exe?!


_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

Just a thought it might require a Restart of Explorer.exe?!

The line

RunWait("rundll32 user32.dll,UpdatePerUserSystemParameters")

is supposed to refresh the entire desktop. Doesn't seem to work.

Tried manually killing explorer.exe and restarting. Didn't make a difference. :unsure:

Thanks anyway.

Share this post


Link to post
Share on other sites

Something like this?

#Include <WinAPI.au3>
_WinAPI_SetSysColors(1, 0xca9a66)

You sir, are a saint! :unsure:

Thank you. I don't know why I had such a hard time with it.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I still see I have a lot of the Help File to read :unsure:

#include <WinAPI.au3>
#include <WindowsConstants.au3>

ConsoleWrite(_GetBackgroundColor() & @CRLF)
ConsoleWrite(_SetBackgroundColor(0xFFFFFF) & @CRLF)

Func _GetBackgroundColor()
    Return _WinAPI_GetSysColor($COLOR_BACKGROUND)
EndFunc   ;==>_GetBackgroundColor

Func _SetBackgroundColor($bColor)
    Return _WinAPI_SetSysColors($COLOR_BACKGROUND, $bColor)
EndFunc   ;==>_SetBackgroundColor
Edited by guinness

_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

I still see I have a lot of the Help File to read :unsure:

#include <WinAPI.au3>
#include <WindowsConstants.au3>

ConsoleWrite(_GetBackgroundColor() & @CRLF)
ConsoleWrite(_SetBackgroundColor(0xFFFFFF) & @CRLF)

Func _GetBackgroundColor()
    Return _WinAPI_GetSysColor($COLOR_BACKGROUND)
EndFunc   ;==>_GetBackgroundColor

Func _SetBackgroundColor($bColor)
    Local $iError = 0
    _WinAPI_SetSysColors($COLOR_BACKGROUND, $bColor)
    If @error Then
        $iError = 1
    EndIf
    Return SetError($iError, 0, $bColor)
EndFunc   ;==>_SetBackgroundColor

Thank you for posting this.

The built-in help for AutoIt is second to none, but there are some examples that I wrestle with. This helps.

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