Windows 11 moving wallpaper

Hello everyone!

As a hobby, I create static wallpapers by overlaying green rectangle with anime characters.

One day, I came across an illustration of a pocket watch, so instead of overlaying it with a green rectangle, I implemented a watch movement using Processing to create a moving wallpaper.

Surprisingly, the code for the moving wallpaper turned out to be shorter than I expected.

import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.HDC;
import com.sun.jna.platform.win32.* ;
import com.sun.jna.win32.StdCallLibrary;

HWND workerW ;
HWND childDC ;
HDC dc_workerW ;
HDC dc_childDC ;

[…]

void setup() {

fullScreen(1);
frameRate(60);

[...]

HWND progman = User32.INSTANCE.FindWindow ( “Progman”, null ) ;
DWORDByReference dbr = new DWORDByReference();
User32.INSTANCE.SendMessageTimeout ( progman, 0x052c, new WPARAM(0), new
LPARAM(0), 0x0, 1000, dbr ) ;

HWND workerW = User32.INSTANCE.FindWindowEx ( progman, null, “workerW”,
null) ;
HDC dc_workerW = User32.INSTANCE.GetDC( workerW );

HWND childDC = User32.INSTANCE.FindWindow ( null, “[sketch_name]” ) ;
HDC dc_childDC = User32.INSTANCE.GetDC( childDC );

HWND rtn_set = User32.INSTANCE.SetParent ( childDC, workerW ) ;

}

That’s all the code you need to add to sketch.

ex; Pocket watch

ex; Video playback

See you again sometime.

1 Like

Hello @FortranGuy ,

I added the sketch name and added latest JAR files but all I get is a gray screen:

  • jna-5.18.0.jar
  • jna-platform-5.18.0.jar

Note:

  • The 4.1.2 did not work here
  • Using W10, Processing 4.4.7

Is something missing in your code?

I am expecting a Windows background with icons on top but just seeing the background fullscreen.

:)

Hello @glv .

Thanks for trying!

In conclusion, this code is currently only for Windows 11.

Of course, when I tested this code, I ran it on Windows 10 and Windows 11.
Unfortunately, it didn’t run on Windows 10…

I followed the steps in the original source and used MS spy++ to check the behavior of Windows 10 and Windows 11.
The point was that each ran in a different way.

Based on the article ( Code Project ) I referenced, I used spy to observe step-by-step execution on Windows 10 and Windows 11.
The point is that they run differently.

Just to be sure, I used a MS spy++ to observe the OS’s standard slideshow, and as expected, it ran clearly differently on Windows 10 and Windows 11.

So I decided to say goodbye to Windows 10 and welcome Windows 11.

Sorry I couldn’t be of much help…

Hello @glv and everyone!

Supplement…

The code with the frame added is shown below:

import processing.awt.PSurfaceAWT;

import java.awt.Component;
import java.awt.Frame;

import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.WString;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.DWORDByReference;
import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.HDC;
import com.sun.jna.platform.win32.* ;
import com.sun.jna.win32.StdCallLibrary;

HWND workerW ; 
HWND childDC ;
HDC dc_workerW ;
HDC dc_childDC ;

void setup() {

  fullScreen(SPAN);

  PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
  PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();
  Frame frame = smoothCanvas.getFrame();
 
  frame.removeNotify();
  frame.setSize(width, height);
  frame.setAlwaysOnTop(true);
  frame.setUndecorated(true);
  frame.setOpacity(0.995f);
  frame.addNotify();
  frame.setLocation (    0, 0);

  colorMode(RGB);
  frameRate(20);
  smooth();
  noStroke();
  textureMode(NORMAL);

  hint(ENABLE_DEPTH_TEST);


  HWND progman = User32.INSTANCE.FindWindow ( "Progman", null ) ;
  DWORDByReference dbr = new DWORDByReference();
  User32.INSTANCE.SendMessageTimeout ( progman, 0x052c, new WPARAM(0), new LPARAM(0), 0x0, 1000, dbr ) ;

  HWND workerW = User32.INSTANCE.FindWindowEx ( progman, null, "workerW", null) ;
  HDC dc_workerW = User32.INSTANCE.GetDC( workerW );

  HWND childDC = User32.INSTANCE.FindWindow ( null, " sketch_name " ) ; 
  HDC dc_childDC = User32.INSTANCE.GetDC( childDC );

  HWND rtn_set = User32.INSTANCE.SetParent ( childDC, workerW ) ; 


}

:grinning_cat: