1

I am currently trying to write a c# programm that changes the color of the active window in the windows 8 desktop window manager. I focused out the registry entry that contains the specific value and changed it to a value of my choice.

What I'm trying to achieve now is that the color is immediately changed without restarting the window manager (in german "desktopfenster manager" - don't know exactly english name of process).

Here is the code to change the value:

RegistryKey key;
public void initialise()
    {
        key = Registry.CurrentUser;
        key = key.OpenSubKey("Software\\Microsoft\\Windows\\DWM",true);
        Object theValue = key.GetValue("ColorizationColor", RegistryValueKind.DWord);
        System.Console.Write("Value before switch: ");
        System.Console.WriteLine(String.Format("{0:X}", theValue));


        System.Console.ReadKey();
    }

    public void setColor()
    {
        key.SetValue("ColorizationColor", unchecked((int) 0xff00ff00u), RegistryValueKind.DWord);
        Object theValue = key.GetValue("ColorizationColor", RegistryValueKind.DWord);
        System.Console.Write("Value after switch: ");
        System.Console.WriteLine(String.Format("{0:X}", theValue));

        System.Console.ReadKey();



    }

Now what I am trying is to send a broadcast message to the window manager to force it to update it's status. Unfortunately, I have never worked with it and cannot figure out what to do exactly.

Google tells me I have to define

 [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    public static extern IntPtr SendMessageTimeout(
        IntPtr hWnd,
        int Msg,
        IntPtr wParam,
        string lParam,
        int fuFlags,
        int uTimeout,
        IntPtr lpdwResult
    );

And then call it in my function like this:

 SendMessageTimeout((IntPtr)0xffff, 0x001A, IntPtr.Zero, "Environment",
                2, 5000, IntPtr.Zero);

This does not work, plus I don't know if I am on the right way here anyway. However, the color changes after relogging into my user account.

Ah, I should add that in the end the programm should randomly change the color of the window by changing the value of

HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor

to get a kind of "Rainbow Window".

I have also given

HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColorBalance

an alpha value of 00 (while ColorizationColor has ff at the beginning)

Lézard
  • 11
  • 2
  • 1
    http://msdn.microsoft.com/en-us/library/windows/desktop/dd388198%28v=vs.85%29.aspx – Hans Passant May 13 '14 at 19:14
  • Could you give me an example? I managed the part which sets the registry value, but it seems like this WM_DWMCOLORIZATIONCOLORCHANGED is a function that makes editing the registry unnecessary. However, I have no idea how to use this function with SendMessageTimeout. Maybe I'm missing the point, the API look pretty weired as I'm not an experienced Windows programmer.... – Lézard May 13 '14 at 22:26
  • Possible duplicate of [How does Windows change Aero Glass color?](http://stackoverflow.com/questions/1487919/how-does-windows-change-aero-glass-color) – Cees Timmerman Jul 31 '16 at 20:56

0 Answers0