Libraryless. Click here for Pure Java version (4249L/29K/92K).
1 | !7 |
2 | |
3 | static int viewSize = 21; |
4 | static int fps = 100, stepSize = 1; |
5 | |
6 | p { |
7 | Class perimeter = hotwire(#1006786); |
8 | set(perimeter, size := viewSize); |
9 | callMainInNewThread(perimeter); |
10 | |
11 | int radius = viewSize/2-2; |
12 | int direction = 0; |
13 | new MouseMover mover; |
14 | mover.endAfterInterference = false; |
15 | mover.blockTimeAfterInterference = 5000; |
16 | mover.enable(); |
17 | while licensed { |
18 | sleep(1000/fps); |
19 | if (mover.blocked()) continue; |
20 | |
21 | Pt p = mousePointer(); |
22 | Rect area = new Rect(p.x-viewSize/2, p.y-viewSize/2, viewSize, viewSize); |
23 | BWImage img = shootScreenBW(area); |
24 | |
25 | L<Pt> points = circlePoints(viewSize/2, viewSize/2, radius); |
26 | final int n = l(points); |
27 | float[] values = new float[n]; |
28 | for i to n: |
29 | values[i] = img.getPixel(points.get(i)); |
30 | values = cyclicBlur(values); |
31 | L<Int> minima = cyclicLocalMinima(values); |
32 | if (empty(minima)) continue; |
33 | final int _direction = direction; |
34 | direction = lowestAccordingTo(minima, func(int i) { moddistance(i, _direction, n) }); |
35 | print("n=" + n + ", minima: " + struct(minima) + ", old direction=" + _direction + ", new direction: " + direction); |
36 | |
37 | Pt p2 = addPts(p, ptMul(stepSize, oneStepPt(points.get(direction), viewSize/2, viewSize/2))); |
38 | |
39 | //print("Moving mouse " + (p2.x-p.x) + "/" + (p2.y-p.y) + " (centroid: " + formatDouble(cx, 2) + "/" + formatDouble(cy, 2) +")"); |
40 | mover.moveMouseImmediate(p2); |
41 | } |
42 | mover.disable(); |
43 | } |
Began life as a copy of #1005823
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006792 |
Snippet name: | Feel The Circle [Mouse Mover] |
Eternal ID of this version: | #1006792/20 |
Text MD5: | b9ec564fd36e07ede1d6f9aed7c84c58 |
Transpilation MD5: | da7dd450faa9295b298ad671573d3dac |
Author: | stefan |
Category: | javax / automation |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-04 06:09:26 |
Source code size: | 1477 bytes / 43 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 479 / 572 |
Version history: | 19 change(s) |
Referenced in: | [show references] |