Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1006792 // Feel The Circle [Mouse Mover]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (4249L/29K/92K).

!7

static int viewSize = 21;
static int fps = 100, stepSize = 1;

p {
  Class perimeter = hotwire(#1006786);
  set(perimeter, size := viewSize);
  callMainInNewThread(perimeter);
  
  int radius = viewSize/2-2;
  int direction = 0;
  new MouseMover mover;
  mover.endAfterInterference = false;
  mover.blockTimeAfterInterference = 5000;
  mover.enable();
  while licensed {
    sleep(1000/fps);
    if (mover.blocked()) continue;
    
    Pt p = mousePointer();
    Rect area = new Rect(p.x-viewSize/2, p.y-viewSize/2, viewSize, viewSize);
    BWImage img = shootScreenBW(area);
    
    L<Pt> points = circlePoints(viewSize/2, viewSize/2, radius);
    final int n = l(points);
    float[] values = new float[n];
    for i to n:
      values[i] = img.getPixel(points.get(i));
    values = cyclicBlur(values);
    L<Int> minima = cyclicLocalMinima(values);
    if (empty(minima)) continue;
    final int _direction = direction;
    direction = lowestAccordingTo(minima, func(int i) { moddistance(i, _direction, n) });
    print("n=" + n + ", minima: " + struct(minima) + ", old direction=" + _direction + ", new direction: " + direction);

    Pt p2 = addPts(p, ptMul(stepSize, oneStepPt(points.get(direction), viewSize/2, viewSize/2)));
    
    //print("Moving mouse " + (p2.x-p.x) + "/" + (p2.y-p.y) + " (centroid: " + formatDouble(cx, 2) + "/" + formatDouble(cy, 2) +")");
    mover.moveMouseImmediate(p2);
  }
  mover.disable();
}

Author comment

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: 405 / 471
Version history: 19 change(s)
Referenced in: [show references]