Package com.esotericpig.jeso.botbuddy
Class BotBuddy
java.lang.Object
com.esotericpig.jeso.botbuddy.BotBuddy
- All Implemented Interfaces:
Duplicable<BotBuddy>
,AutoCloseable
BotBuddy is a simple wrapper aroundjava.awt.Robot
. Example: BotBuddy buddy = BotBuddy.builder().autoDelay(33).autoWaitForIdle(false).build(); buddy.paste(999,493,"Fish").enter(1427,500,"Sakana"); buddy.click(1853,1015).delayLong(); Construct a class: BotBuddy.builder().build(); There's a Safe Mode that throwsUserIsActiveException
if the user moves the mouse. In addition, the pressed keys and pressed mouse buttons are stored internally if Release Mode is on (on by default), so that you can release everything currently pressed down to alleviate problems for the user when active. try { buddy.beginSafeMode() .enter(1470,131,"Mommy") .delay(2000) // Move your mouse during this time .enter(1470,131,"Daddy") .endSafeMode(); } catch(UserIsActiveException ex) { // Release all keys and/or mouse buttons pressed down by our automatic operations buddy.releasePressed(); // If you move your mouse, "Daddy" will not be executed System.out.println("User is active! Stopping all automatic operations."); } If you click into a virtual machine, you can change the OS for Shortcuts: buddy.setOSFamily(OSFamily.MACOS); SeeBotBuddyCode
for a simple scripting "language" for this class. SeeBotBuddyCodeApp
for a simple app that can take in a file that uses BotBuddyCode.
Similar Projects:
- Robot-Utils by Denys Shynkarenko (@Denysss) [GitHub]
- Automaton by Renato Athaydes (@renatoathaydes) [GitHub]
Getting mouse coordinates:
- Linux: Install "xdotool" and do:
xdotool getmouselocation
- Java:
getCoords()
,getXCoord()
,getYCoord()
- Author:
- Jonathan Bradley Whited
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
BotBuddy.Builder constructs aBotBuddy
using the Builder Design Pattern.static interface
This class can really be used for any automated operations, not just keyboard shortcuts.static class
class
-
Field Summary
Modifier and TypeFieldDescriptionprotected Robot
protected Clipboard
static final int
static final int
For double clicks, etc.static final int
After doing a series of commands, for waiting for a webpage to load, etc.static final int
For auto delay, or for a manual delay between fast and long if auto delay is set differently.protected int
protected int
protected boolean
protected boolean
protected boolean
protected int
protected int
protected int
protected OSFamily
protected LinkedList<Integer>
protected LinkedList<Integer>
protected int
protected Point
protected int
protected Deque<BotBuddy.Stash>
protected Toolkit
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbeep()
static BotBuddy.Builder
builder()
static BotBuddy.Builder
builder
(GraphicsDevice screen) static BotBuddy.Builder
checkIfSafe
(Point coords) click()
click
(int button) click
(int x, int y) click
(int x, int y, int button) clicks
(int... buttons) void
close()
copy
(String text, ClipboardOwner owner) delay
(int delay) doubleClick
(int button) doubleClick
(int x, int y) doubleClick
(int x, int y, int button) drag
(int fromX, int fromY, int toX, int toY) drag
(int fromX, int fromY, int toX, int toY, int button) dup()
enter()
enter
(int x, int y) int
getBot()
getClip()
static Point
int
int
int
int
int
getPixel
(int x, int y) int
int
int
int
getTool()
static int
static int
boolean
boolean
static boolean
boolean
boolean
leftClick
(int x, int y) middleClick
(int x, int y) move
(int x, int y) paste()
paste
(int x, int y) pressButton
(int button) pressButton
(int x, int y, int button) pressButtons
(int... buttons) pressKey
(int keyCode) pressKey
(int x, int y, int keyCode) pressKeys
(int... keyCodes) printScreen
(int width, int height) printScreen
(int x, int y, int width, int height) printScreen
(Rectangle screenRect) releaseButton
(int button) releaseButton
(int x, int y, int button) releaseButtons
(int... buttons) releaseKey
(int keyCode) releaseKey
(int x, int y, int keyCode) releaseKeys
(int... keyCodes) rightClick
(int x, int y) rollButtons
(int... buttons) rollKeys
(int... keyCodes) setAutoDelay
(boolean isAutoDelay) setAutoDelay
(int autoDelay) setAutoWaitForIdle
(boolean isAutoWaitForIdle) setDefaultButton
(int defaultButton) setFastDelay
(int fastDelay) setLeftButton
(int leftButton) setLongDelay
(int longDelay) setMiddleButton
(int middleButton) setOSFamily
(OSFamily osFamily) setReleaseMode
(boolean isReleaseMode) setRightButton
(int rightButton) setShortDelay
(int shortDelay) shortcut
(BotBuddy.Shortcut shortcut) stash()
type
(int keyCode) type
(int x, int y, int keyCode) protected BotBuddy
types
(int... keyCodes) typeUnsurely
(int x, int y, String text) typeUnsurely
(String text) unstash()
wheel
(int amount)
-
Field Details
-
DEFAULT_FAST_DELAY
public static final int DEFAULT_FAST_DELAYFor double clicks, etc.- See Also:
-
DEFAULT_LONG_DELAY
public static final int DEFAULT_LONG_DELAYAfter doing a series of commands, for waiting for a webpage to load, etc.- See Also:
-
DEFAULT_SHORT_DELAY
public static final int DEFAULT_SHORT_DELAYFor auto delay, or for a manual delay between fast and long if auto delay is set differently.- See Also:
-
DEFAULT_AUTO_DELAY
public static final int DEFAULT_AUTO_DELAY- See Also:
-
bot
-
clip
-
defaultButton
protected int defaultButton -
fastDelay
protected int fastDelay -
isAutoDelay
protected boolean isAutoDelay -
isReleaseMode
protected boolean isReleaseMode -
isSafeMode
protected boolean isSafeMode -
leftButton
protected int leftButton -
longDelay
protected int longDelay -
middleButton
protected int middleButton -
osFamily
-
pressedButtons
-
pressedKeys
-
rightButton
protected int rightButton -
safeCoords
-
shortDelay
protected int shortDelay -
stashes
-
tool
-
-
Constructor Details
-
BotBuddy
-
BotBuddy
- Throws:
AWTException
HeadlessException
-
-
Method Details
-
builder
- Throws:
HeadlessException
-
builder
- Throws:
HeadlessException
-
builder
public static BotBuddy.Builder builder(GraphicsDevice screen) throws AWTException, HeadlessException - Throws:
AWTException
HeadlessException
-
getCoords
- Throws:
HeadlessException
SecurityException
-
isHeadless
public static boolean isHeadless() -
getXCoord
- Throws:
HeadlessException
SecurityException
-
getYCoord
- Throws:
HeadlessException
SecurityException
-
dup
- Specified by:
dup
in interfaceDuplicable<BotBuddy>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Since:
- 0.3.6
-
beep
-
beginFastMode
-
beginSafeMode
-
checkIfSafe
-
checkIfSafe
-
clearPressed
-
clearPressedButtons
-
clearPressedKeys
-
click
-
click
-
click
-
click
-
clicks
-
copy
-
copy
-
delay
-
delayAuto
-
delayFast
-
delayLong
-
delayShort
-
doubleClick
-
doubleClick
-
doubleClick
-
doubleClick
-
drag
-
drag
-
endFastMode
-
endSafeMode
-
enter
-
enter
-
enter
-
enter
-
leftClick
-
leftClick
-
middleClick
-
middleClick
-
move
-
paste
-
paste
-
paste
-
paste
-
pressButton
-
pressButton
-
pressButtons
-
pressKey
-
pressKey
-
pressKeys
-
printScreen
- Throws:
SecurityException
-
printScreen
- Throws:
SecurityException
-
printScreen
- Throws:
SecurityException
-
printScreen
- Throws:
SecurityException
-
releaseButton
-
releaseButton
-
releaseButtons
-
releaseButtons
-
releaseKey
-
releaseKey
-
releaseKeys
-
releaseKeys
-
releasePressed
-
rightClick
-
rightClick
-
rollButtons
-
rollKeys
-
shortcut
-
stash
-
type
-
type
- Since:
- 0.3.5
-
type
- Since:
- 0.3.5
-
type
- Since:
- 0.3.5
-
type
- Since:
- 0.3.5
-
types
-
typeUnsurely
- Since:
- 0.3.5
-
typeUnsurely
- Since:
- 0.3.5
-
unstash
-
waitForIdle
-
wheel
-
setAutoDelay
-
setAutoDelay
-
setAutoWaitForIdle
-
setBot
-
setClip
-
setDefaultButton
-
setFastDelay
-
setLeftButton
-
setLongDelay
-
setMiddleButton
-
setOSFamily
-
setReleaseMode
-
setRightButton
-
setShortDelay
-
setTool
-
getAutoDelay
public int getAutoDelay() -
isAutoDelay
public boolean isAutoDelay() -
isAutoWaitForIdle
public boolean isAutoWaitForIdle() -
getBot
-
getClip
-
getDefaultButton
public int getDefaultButton() -
getFastDelay
public int getFastDelay() -
getLeftButton
public int getLeftButton() -
getLongDelay
public int getLongDelay() -
getMiddleButton
public int getMiddleButton() -
getOSFamily
-
getPixel
-
getPixel
-
isReleaseMode
public boolean isReleaseMode() -
getRightButton
public int getRightButton() -
isSafeMode
public boolean isSafeMode() -
getScreenHeight
public int getScreenHeight() -
getScreenSize
-
getScreenWidth
public int getScreenWidth() -
getShortDelay
public int getShortDelay() -
getTool
-