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

29
LINES

< > BotCompany Repo | #1025031 // dm_moveMouseAndClick

JavaX fragment (include) [tags: use-pretranspiled]

Uses 408K of libraries. Click here for Pure Java version (3898L/25K).

// returns true iff clicked
sbool dm_moveMouseAndClick(Rect r, S targetName, O... _) {
  if (r == null) false;
  optPar O enabled; // func -> bool
  double waitBeforeClick = doublePar waitBeforeClick(_, 1.0);
  print("Moving mouse to " + targetName + "!!!!");
  O mover = vmBus_query mouseMover();
  if (mover == null) ret false with print("No mover");
  callWithImportExport(mover, 'moveMouse, centerOfRect(r));
  print("MOVED");
  long startTime = sysNow();
  while (licensed() && sysNow() < startTime+toMS(waitBeforeClick)) {
    if (isFalse_callF(enabled)) false;
    if (isTrue_rcall blocked(mover))
      ret false with print("INTERFERENCE, EXITING");
    sleepSeconds(0.05);
  }
  if (!r.contains(mouseLocationPt()))
    ret false with print("Mouse outside of target area, exiting");
    
  print("CLICKING!");
  rcall click(mover);
  print("CLICKED!");
  true;
}

sbool dm_moveMouseAndClick(S targetName, Rect r, O... _) {
  ret dm_moveMouseAndClick(r, targetName, _);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1025031
Snippet name: dm_moveMouseAndClick
Eternal ID of this version: #1025031/5
Text MD5: d85cc3ec6643fcd5ef7004f1b602168e
Transpilation MD5: a235d023df6a0f3dbc9b97e29ba3cc26
Author: stefan
Category: javax / visual bots
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-09-21 22:26:43
Source code size: 1006 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 333
Version history: 4 change(s)
Referenced in: [show references]