Windows限定です。すべて貫通するので移動ができません。
ざっと試した限りは動いてそうですが、何か問題があるかもしれません。
jna-5.6.0.jar
・jna-platform-5.6.0.jar
を、エディタにドロップするなりして使えるようにしておきます。
java-native-access/jna: Java Native Access
Processing
1import processing.awt.PSurfaceAWT;
2
3import java.awt.Component;
4import java.awt.Frame;
5
6import com.sun.jna.Native;
7import com.sun.jna.platform.win32.User32;
8import com.sun.jna.platform.win32.WinDef;
9import com.sun.jna.platform.win32.WinUser;
10
11void setup() {
12 size(300, 150);
13 frameRate(1);
14 stroke(255);
15 textSize(72);
16
17 PSurfaceAWT awtSurface = (PSurfaceAWT)surface;
18 PSurfaceAWT.SmoothCanvas smoothCanvas = (PSurfaceAWT.SmoothCanvas)awtSurface.getNative();
19 Frame frame = smoothCanvas.getFrame();
20
21 frame.removeNotify();
22 frame.setSize(width, height);
23 frame.setAlwaysOnTop(true);
24 frame.setUndecorated(true);
25 frame.setOpacity(0.5f);
26 frame.addNotify();
27
28 setTransparent(frame);
29}
30
31void draw() {
32 background(0);
33 if (second() % 2 == 0)
34 text(nf(hour(), 2) + ":" + nf(minute(), 2), 50, 100);
35 else
36 text(nf(hour(), 2) + " " + nf(minute(), 2), 50, 100);
37}
38
39// [swing - Java: Making a window click-through (including text/images) - Stack Overflow](https://stackoverflow.com/questions/11217660/java-making-a-window-click-through-including-text-images)
40private static void setTransparent(Component w) {
41 WinDef.HWND hwnd = getHWnd(w);
42 int wl = User32.INSTANCE.GetWindowLong(hwnd, WinUser.GWL_EXSTYLE);
43 wl = wl | WinUser.WS_EX_LAYERED | WinUser.WS_EX_TRANSPARENT;
44 User32.INSTANCE.SetWindowLong(hwnd, WinUser.GWL_EXSTYLE, wl);
45}
46
47private static WinDef.HWND getHWnd(Component w) {
48 WinDef.HWND hwnd = new WinDef.HWND();
49 hwnd.setPointer(Native.getComponentPointer(w));
50 return hwnd;
51}
参考
swing - Java: Making a window click-through (including text/images) - Stack Overflow
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/10/13 04:04