VelvetElvis Posted May 11, 2011 Share Posted May 11, 2011 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. 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! Link to comment Share on other sites More sharing options...
guinness Posted May 11, 2011 Share Posted May 11, 2011 Just a thought it might require a Restart of Explorer.exe?! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
VelvetElvis Posted May 11, 2011 Author Share Posted May 11, 2011 Just a thought it might require a Restart of Explorer.exe?!The lineRunWait("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. Thanks anyway. Link to comment Share on other sites More sharing options...
JFX Posted May 11, 2011 Share Posted May 11, 2011 Something like this? #Include <WinAPI.au3> _WinAPI_SetSysColors(1, 0xca9a66) Link to comment Share on other sites More sharing options...
VelvetElvis Posted May 11, 2011 Author Share Posted May 11, 2011 Something like this? #Include <WinAPI.au3> _WinAPI_SetSysColors(1, 0xca9a66) You sir, are a saint! Thank you. I don't know why I had such a hard time with it. Link to comment Share on other sites More sharing options...
guinness Posted May 11, 2011 Share Posted May 11, 2011 (edited) I still see I have a lot of the Help File to read #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 November 19, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
VelvetElvis Posted May 13, 2011 Author Share Posted May 13, 2011 I still see I have a lot of the Help File to read #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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now