I made a test in C++/WinRT/Console from scratch in VS 2022, so I hope it will work with VS Code...
#include <Unknwn.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/Windows.UI.ViewManagement.h>
#include <winrt/Windows.UI.h>
#include <winrt/Windows.UI.XAML.Media.h>
#include <winrt/Windows.UI.XAML.h>
#include <winrt/Windows.Foundation.h>
#include <stdio.h>
using namespace winrt;
using namespace Windows::Foundation;
struct CNotify
{
void NotifyColors()
{
colorValuesChangedRevoker = uiSettings.ColorValuesChanged(winrt::auto_revoke, [this](winrt::Windows::UI::ViewManagement::UISettings const&, winrt::Windows::Foundation::IInspectable const&)
{
this->UpdateAccentColor();
});
}
private:
Windows::UI::ViewManagement::UISettings uiSettings;
Windows::UI::ViewManagement::UISettings::ColorValuesChanged_revoker colorValuesChangedRevoker;
void UpdateAccentColor();
};
void CNotify::UpdateAccentColor()
{
Windows::UI::Color accentColor = uiSettings.GetColorValue(Windows::UI::ViewManagement::UIColorType::Accent);
//winrt::hstring hsCoplorName = Windows::UI::ColorHelper::ToDisplayName(accentColor);
//printf("Accent Color : (%d, %d, %d, %d) - %ls\n", accentColor.A, accentColor.R, accentColor.G, accentColor.B, hsCoplorName.c_str());
printf("Accent Color : (%d, %d, %d, %d)\n", accentColor.A, accentColor.R, accentColor.G, accentColor.B);
}
int main()
{
init_apartment();
CNotify notify;
notify.NotifyColors();
INPUT_RECORD rec;
HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE);
DWORD nEnreg;
printf("Waiting for color change (Escape to exit)...\n");
for (;;)
{
ReadConsoleInput(hConsole, &rec, 1, &nEnreg);
if (rec.EventType == KEY_EVENT)
{
if (!rec.Event.KeyEvent.bKeyDown && rec.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
break;
}
}
return(0);
}