Jump to content

Recommended Posts

Posted

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!

Posted

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

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

  On 5/11/2011 at 11:56 AM, 'guinness said:

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.

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

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

  On 5/11/2011 at 6:44 PM, 'guinness said:

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...