Download Jar. Libraryless. Click here for Pure Java version (2994L/19K).
1 | !7 |
2 | |
3 | static int windowSize = 11; // odd should look nice. Set to 1 for an invisible window |
4 | static int clickDelay = 0; // Delay in ms between closing window and forwarding click. 0 seems to work fine. |
5 | static int trackingSpeed = 10; // How often to move the window (ms) |
6 | |
7 | p { |
8 | final new JWindow window; |
9 | window.setSize(windowSize, windowSize); |
10 | window.setVisible(true); |
11 | window.setAlwaysOnTop(true); |
12 | JPanel panel = singleColorPanel(Color.red); |
13 | window.setContentPane(panel); |
14 | revalidate(window); |
15 | final new Robot robot; |
16 | panel.addMouseListener(new MouseAdapter { |
17 | // public void mousePressed(final MouseEvent e) {} |
18 | |
19 | public void mouseReleased(final MouseEvent e) { |
20 | print("release! " + e); |
21 | window.setVisible(false); |
22 | int b = e.getButton(); |
23 | final int mod = |
24 | b == 1 ? InputEvent.BUTTON1_DOWN_MASK |
25 | : b == 2 ? InputEvent.BUTTON2_DOWN_MASK |
26 | : InputEvent.BUTTON3_DOWN_MASK; |
27 | swingLater(clickDelay, r { |
28 | print("clicking " + mod); |
29 | robot.mousePress(mod); |
30 | robot.mouseRelease(mod); |
31 | }); |
32 | } |
33 | }); |
34 | |
35 | swingEvery(window, trackingSpeed, r { |
36 | Point p = getMouseLocation(); |
37 | window.setLocation(p.x-windowSize/2, p.y-windowSize/2); |
38 | //print("moving"); |
39 | }); |
40 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, hfqflyfjmcnm, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005565 |
Snippet name: | 1-Pixel Window Mouse Tracking & Forwarding [works, just not for dragging] |
Eternal ID of this version: | #1005565/2 |
Text MD5: | d5553bd27682e57e0a90d098ff8fdb12 |
Transpilation MD5: | df12aadad53154425cd931df708f43d6 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-10-31 12:49:17 |
Source code size: | 1287 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 1718 / 2623 |
Version history: | 1 change(s) |
Referenced in: | [show references] |