Libraryless. Click here for Pure Java version (4944L/34K/114K).
!752 static int viewSize = 21; static int interval = 100; static float speed = 0.3f; static float minOffset = 0f; // 0.5f; // offset needed to move at all volatile sbool useDarkCentroid = false; static JCheckBox cbDark; p { awt { showControls(jcenteredLine( cbDark = jCheckBox("Focus on dark things", useDarkCentroid, r { useDarkCentroid = cbDark.isSelected(); }) )); } new MouseMover mover; mover.endAfterInterference = false; mover.blockTimeAfterInterference = 1000; mover.enable(); while licensed { sleep(interval); if (mover.blocked()) continue; Point p = mouseLocation(); Rect area = new Rect(p.x-viewSize/2, p.y-viewSize/2, viewSize, viewSize); BWImage img = shootScreenBW(area); Pair<Float, Float> c = bwCentroid(img, useDarkCentroid); ImageSurface is = quickShowZoomedImage(img.toRGB(), 4); float cx = c.a-viewSize/2, cy = c.b-viewSize/2; //Pt p2 = new Pt(iround(p.x+cx*speed), iround(p.y+cy*speed)); Pt p2 = new Pt(p.x+signWithThreshold(cx, minOffset), p.y+signWithThreshold(cy, minOffset)); print("Moving mouse " + (p2.x-p.x) + "/" + (p2.y-p.y) + " (centroid: " + formatDouble(cx, 2) + "/" + formatDouble(cy, 2) +")"); mover.moveMouseImmediate(p2); } mover.disable(); }
Began life as a copy of #1005820
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005823 |
Snippet name: | Continually move mouse to centroid; block for 1 second on interference |
Eternal ID of this version: | #1005823/1 |
Text MD5: | 3fcb25c866100e123eedc6e4897ad173 |
Transpilation MD5: | ff9159698f8a7e8312923f681e740593 |
Author: | stefan |
Category: | javax / automation |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-10 17:30:07 |
Source code size: | 1313 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 536 / 651 |
Referenced in: | [show references] |