windows-caption-color

0.0.6 • Public • Published

windows-caption-color

It's a node extension to get the caption color of an active windows in Windows 8+. In non-Windows, it will always return false.

Installion

npm install windows-caption-color --save

Requirement

Node 0.12+ / Electron / nwjs 0.12+

Example

require('windows-caption-color').get(function(err, ret) {
    if (err === null) {
        console.log(ret);
    }
});

Will return:

{
    "dwm": {
        "hsv": "c73eb8d0",
        "opaque": true,
        "a": 0.78,
        "r": 62,
        "g": 184,
        "b": 208
    },
    "reg": {
        "hsv": "af4adbf8",
        "balance": 4,
        "a": 0.69,
        "r": 74,
        "g": 219,
        "b": 248
    }
}

dwm is from DwmGetColorizationColor API, description: https://msdn.microsoft.com/en-us/library/windows/desktop/aa969513(v=vs.85).aspx.

reg is from HKCU\Software\Microsoft\Windows\DWM.

However, the result from GetSysColor(COLOR_ACTIVECAPTION) is wrong.

Example

In Windows 10, the following code can set your document.body's background color same as the caption color.

    require('windows-caption-color').get(function(err, ret) {
        if (err === null) {
            window.document.body.style.background = `rgba(${ret.reg.r}${ret.reg.g}${ret.reg.b}${ret.reg.a})`;
        }
    });

And, screenshots here.

Windows 10

Windows 10

Windows 8.1

Windows 8.1

Windows 7

Windows 7

Why?

If you want to use it directly, you will get a wrong result. And you have to refer to the following article.

http://stackoverflow.com/questions/24555827/how-to-get-title-bar-color-of-wpf-window-in-windows-8-1

http://stackoverflow.com/questions/3560890/vista-7-how-to-get-glass-color

License

The MIT License

Package Sidebar

Install

npm i windows-caption-color

Weekly Downloads

0

Version

0.0.6

License

MIT

Last publish

Collaborators

  • zsx