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).

1  
// returns true iff clicked
2  
sbool dm_moveMouseAndClick(Rect r, S targetName, O... _) {
3  
  if (r == null) false;
4  
  optPar O enabled; // func -> bool
5  
  double waitBeforeClick = doublePar waitBeforeClick(_, 1.0);
6  
  print("Moving mouse to " + targetName + "!!!!");
7  
  O mover = vmBus_query mouseMover();
8  
  if (mover == null) ret false with print("No mover");
9  
  callWithImportExport(mover, 'moveMouse, centerOfRect(r));
10  
  print("MOVED");
11  
  long startTime = sysNow();
12  
  while (licensed() && sysNow() < startTime+toMS(waitBeforeClick)) {
13  
    if (isFalse_callF(enabled)) false;
14  
    if (isTrue_rcall blocked(mover))
15  
      ret false with print("INTERFERENCE, EXITING");
16  
    sleepSeconds(0.05);
17  
  }
18  
  if (!r.contains(mouseLocationPt()))
19  
    ret false with print("Mouse outside of target area, exiting");
20  
    
21  
  print("CLICKING!");
22  
  rcall click(mover);
23  
  print("CLICKED!");
24  
  true;
25  
}
26  
27  
sbool dm_moveMouseAndClick(S targetName, Rect r, O... _) {
28  
  ret dm_moveMouseAndClick(r, targetName, _);
29  
}

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: 192 / 245
Version history: 4 change(s)
Referenced in: [show references]