0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Processing】なんとなく動く壁紙をつくるヒント

Last updated at Posted at 2025-09-15

はじめに

ProcessingはFortran/COBOLしか知らない私からすると比較的簡単に数式を画像表現できるツールだ。

 「動く壁紙」

ある日そんな記事が目に入った。
しかし残念だがその記事はProcessing版ではなかった。深堀してみてもAIを試験実装した先生の答えは壁紙保存後にレジストリ更新する程度しか教えてはくれなかった。

 「所詮AIなんてArtificial Incompetence[人工無能]よね」

検索する都度様々な女性声優ボイスでこのフレーズが脳内再生されたのは言うまでもない。

 「なんでもは知らないわよ 知ってることだけ」

そんな某女性声優の声が響いたとき私は思った。
「なら教えてやろう、Fortran/COBOL使いの無能とやらを…」

参考にしたもの

https://www.codeproject.com/articles/Draw-Behind-Desktop-Icons-in-Windows-plus
https://qiita.com/utasimaru/items/494796bf725ac11a4883
https://teratail.com/questions/297476
https://mvnrepository.com/artifact/net.java.dev.jna/jna
https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform

準備するもの

・Windows11で動作するProcessing環境構築
・JNAおよびJNA-PlatformをProcessingに実装
でも一番重要なものは、「既に動作するProcessingのコード」

コードのヒント

【何】を【どこ】にコードする

実はこれに気付ければ 「既に動作するProcessingのコード」 は概ね 「動く壁紙」 に化ける。
※JNAおよびJNA-Platformのimportはコード済とする。

【何】

// 1. Workerw を生やす
  HWND progman = User32.INSTANCE.FindWindow ( "Progman", null ) ;
  User32.INSTANCE.SendMessageTimeout ( progman, 0x052c, new WPARAM(0), new LPARAM(0), 0x0, 1000, dbr ) ;

// 2. WorkerW の DC を拾う
  HWND workerW = User32.INSTANCE.FindWindowEx ( progman, null, "workerW", null) ; 
  HDC dc_workerW = User32.INSTANCE.GetDC( workerW );

// 3. スケッチの DC を拾う
  HWND childDC = User32.INSTANCE.FindWindow ( null, "スケッチ名" ) ; 
  HDC dc_childDC = User32.INSTANCE.GetDC( childDC );

// 4. WorkerW DC と スケッチ DC を繋ぐ
  HWND rtn_set = User32.INSTANCE.SetParent ( childDC, workerW ) ; 

【どこ】

void setup() 内のラスト行あたり

さいごに

この方式で生成したexeプログラムがコケると、javaw.exe(OpenJDK Platform binary)がリソースとして残る。そんなリソースを解放する場合はタスクマネージャーからOpenJDK Platform binary プロセスの「タスクの終了」をすることをお勧めする。

できあがりサンプル

 【アナログ時計】

 【動画】※音声あり

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?