import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
// returns true iff clicked
import java.text.NumberFormat;
import org.jnativehook.GlobalScreen;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyAdapter;
class main {
static boolean dm_moveMouseAndClick(Rect r, String targetName, Object... __) {
if (r == null) return false;
Object enabled = (Object) (optPar("enabled",__)); // func -> bool
double waitBeforeClick = doublePar("waitBeforeClick",__, 1.0);
print("Moving mouse to " + targetName + "!!!!");
Object mover = vmBus_query("mouseMover");
if (mover == null) { print("No mover"); return false; }
callWithImportExport(mover, "moveMouse", centerOfRect(r));
print("MOVED");
long startTime = sysNow();
while (licensed() && sysNow() < startTime+toMS(waitBeforeClick)) {
if (isFalse_callF(enabled)) return false;
if (isTrue_rcall("blocked",mover))
{ print("INTERFERENCE, EXITING"); return false; }
sleepSeconds(0.05);
}
if (!r.contains(mouseLocationPt()))
{ print("Mouse outside of target area, exiting"); return false; }
print("CLICKING!");
rcall("click",mover);
print("CLICKED!");
return true;
}
static boolean dm_moveMouseAndClick(String targetName, Rect r, Object... __) {
return dm_moveMouseAndClick(r, targetName, __);
}
static A optPar(ThreadLocal tl, A defaultValue) {
A a = tl.get();
if (a != null) {
tl.set(null);
return a;
}
return defaultValue;
}
static A optPar(ThreadLocal tl) {
return optPar(tl, null);
}
static Object optPar(Object[] params, String name) {
return optParam(params, name);
}
static Object optPar(String name, Object[] params) {
return optParam(params, name);
}
static Object optPar(String name, Map params) {
return optParam(name, params);
}
static A optPar(Object[] params, String name, A defaultValue) {
return optParam(params, name, defaultValue);
}
static A optPar(String name, Object[] params, A defaultValue) {
return optParam(params, name, defaultValue);
}
static double doublePar(String name, Object[] __, double defaultValue) {
Number n = (Number) (optPar(name, __));
return n == null? defaultValue : n.doubleValue();
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
static boolean print_silent = false; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal