-4

So I am trying to make my own wallpaper engine (for Windows 11) to render OpenGL shaders on my desktop wallpaper. However, I am facing a problem. I found out that I need to get a WorkerW window and set it as the parent of the window where I am rendering the shaders.

The problem is that the code to spawn the WorkerW window just returns 0. I looked in the Win32 API documentation, and that means it failed.

I was wondering — did the new Windows 11 update break that method, or am I doing something wrong?

Here is the relevant part of the code that is failing:

atomic<HWND> workerRef(nullptr);
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) {
    if (FindWindowEx(hWnd, NULL, "SHELLDLL_DefView", NULL) == NULL) {
        return TRUE;
    }
    HWND worker = FindWindowEx(NULL, hWnd, "WorkerW", NULL);
    if (worker != NULL) {
        workerRef = worker;
        cout << worker << endl;
        return TRUE;
    }
    return FALSE;
}

HWND getWorkerW() {
    HWND progman = FindWindow("Progman", NULL);
    if (!progman) {
        cout << "failed to get progman";
        exit(-1);
    } 
    // it gets here with no problem
    SendMessage(progman, 0x052C, (WPARAM)0xD, (LPARAM)0); // returns 0 (fails)
    SendMessage(progman, 0x052C, (WPARAM)0xD, (LPARAM)1); // returns 0 (fails)
    EnumWindows(EnumWindowsProc, 0);
    return workerRef.load(); // returns 0 (fails)
}

This code is just a translation to C++ from the Java code provided as an example on this website (I don’t know Java, so I used AI to translate it — which may have introduced mistakes): https://dynamicwallpaper.readthedocs.io/en/docs/dev/make-wallpaper.html

Any relevant documentation is welcome, and I am open to suggestions if there is a better way of doing this.

3
  • 1
    How to translate code: Step 1: Fully understand the behaviour described by the source code. This means you need to know that language fairly well. Step 2: Implement the behaviour of the source program exactly in the new language following the new language's best practices and observing its idioms. This means you need to know the new language fairly well. Step 3: Exhaustively test the new program against the original program to ensure identical behaviour. Commented yesterday
  • 1
    You MUST know both languages, and the current crop of AIs don't know any languages. They just know what tokens are statistically likely to follow other tokens given your initial prompt. Commented yesterday
  • 1
    This relies on undocumented things, and things that are undocumented may change, disappear, or stop working at any time. Commented yesterday

1 Answer 1

3

This method has been invalid since Windows 11 24H2.

Windows 11, version 24H2 known issues and notifications

Windows 11 24H2 has made some changes to the WorkerW window. It now disappears immediately after the fade-in/out effect that appears when changing wallpapers (instead of remaining in place so you can draw wallpapers on it). Since users typically don't change wallpapers frequently, this is actually an optimization that saves a window of memory.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.