Package org.sikuli.script
Class Mouse
- java.lang.Object
-
- org.sikuli.script.Mouse
-
public class Mouse extends java.lang.Object
Main pupose is to coordinate the mouse usage among threads
At any one time, the mouse has one owner (usually a Region object)
who exclusively uses the mouse, all others wait for the mouse to be free again
if more than one possible owner is waiting, the next owner is uncertain
It is detected, when the mouse is moved external from the workflow, which can be used for appropriate actions (e.g. pause a script)
the mouse can be blocked for a longer time, so only this owner can use the mouse (like some transactional processing)
Currently deadlocks and infinite waits are not detected, but should not happen ;-)
Contained are methods to use the mouse (click, move, button down/up) as is
-
-
Field Summary
Fields Modifier and Type Field Description static int
LEFT
static int
MIDDLE
static int
RIGHT
static int
WHEEL_DOWN
static int
WHEEL_STEP_DELAY
static int
WHEEL_UP
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Location
at()
static Location
click(Location loc, java.lang.String action, java.lang.Integer... args)
to click (left, right, middle - single or double) at the given location using the given button only useable for local screens timing parameters:
- one value
< 0 wait before mouse down
> 0 wait after mouse up
- 2 or 3 values 1st wait before mouse down
2nd wait after mouse up
3rd inner wait (milli secs, cut to 1000): pause between mouse down and up (Settings.ClickDelay) wait before and after: > 9 taken as milli secs - 1 ...static void
down(int buttons)
press and hold the given buttonsButton
static int
getMouseMovedResponse()
current setting what to do if mouse is moved outside Sikuli's mouse protectionstatic int
getRandom()
static boolean
hasMoved()
check if mouse was moved since last mouse actionstatic boolean
hasRandom()
static void
init()
static int
move(int xoff, int yoff)
move the mouse from the current position to the offset position given by the parametersstatic int
move(Location loc)
move the mouse to the given location (local and remote)static void
randomize()
static void
randomize(long seed)
static void
reset()
static void
resetRandom()
static void
setMouseMovedAction(int movedAction)
what to do if mouse is moved outside Sikuli's mouse protection
- Mouse.MouseMovedIgnore (0) ignore it (default)
- Mouse.MouseMovedShow (1) show and ignore it
- Mouse.MouseMovedPause (2) show it and pause until user says continue
(2 not implemented yet - 1 is used)static void
setMouseMovedCallback(java.lang.Object callBack)
what to do if mouse is moved outside Sikuli's mouse protection
only 3 is honored:
in case of event the user provided callBack.happened is calledstatic void
setMouseMovedHighlight(boolean state)
static void
setRandom()
static void
setRandom(int randomOffset)
static void
up()
release all buttonsstatic void
up(int buttons)
release the given buttonsButton
static void
wheel(int direction, int steps)
move mouse using mouse wheel in the given direction the given steps
the result is system dependent
-
-
-
Field Detail
-
LEFT
public static final int LEFT
- See Also:
- Constant Field Values
-
MIDDLE
public static final int MIDDLE
- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
- See Also:
- Constant Field Values
-
WHEEL_UP
public static final int WHEEL_UP
- See Also:
- Constant Field Values
-
WHEEL_DOWN
public static int WHEEL_DOWN
-
WHEEL_STEP_DELAY
public static final int WHEEL_STEP_DELAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public static void init()
-
at
public static Location at()
-
reset
public static void reset()
-
getMouseMovedResponse
public static int getMouseMovedResponse()
current setting what to do if mouse is moved outside Sikuli's mouse protection- Returns:
- current setting see
setMouseMovedAction(int)
-
setMouseMovedAction
public static void setMouseMovedAction(int movedAction)
what to do if mouse is moved outside Sikuli's mouse protection
- Mouse.MouseMovedIgnore (0) ignore it (default)
- Mouse.MouseMovedShow (1) show and ignore it
- Mouse.MouseMovedPause (2) show it and pause until user says continue
(2 not implemented yet - 1 is used)- Parameters:
movedAction
- value
-
setMouseMovedCallback
public static void setMouseMovedCallback(java.lang.Object callBack)
what to do if mouse is moved outside Sikuli's mouse protection
only 3 is honored:
in case of event the user provided callBack.happened is called- Parameters:
callBack
- ObserverCallBack
-
setMouseMovedHighlight
public static void setMouseMovedHighlight(boolean state)
-
hasMoved
public static boolean hasMoved()
check if mouse was moved since last mouse action- Returns:
- true/false
-
click
public static Location click(Location loc, java.lang.String action, java.lang.Integer... args)
to click (left, right, middle - single or double) at the given location using the given button only useable for local screens timing parameters:
- one value
< 0 wait before mouse down
> 0 wait after mouse up
- 2 or 3 values 1st wait before mouse down
2nd wait after mouse up
3rd inner wait (milli secs, cut to 1000): pause between mouse down and up (Settings.ClickDelay) wait before and after: > 9 taken as milli secs - 1 ... 9 are seconds- Parameters:
loc
- where to click (not null)action
- L,R,M left, right, middle - D means double clickargs
- timing parameters- Returns:
- the location
-
randomize
public static void randomize()
-
randomize
public static void randomize(long seed)
-
getRandom
public static int getRandom()
-
setRandom
public static void setRandom()
-
setRandom
public static void setRandom(int randomOffset)
-
resetRandom
public static void resetRandom()
-
hasRandom
public static boolean hasRandom()
-
move
public static int move(Location loc)
move the mouse to the given location (local and remote)- Parameters:
loc
- Location- Returns:
- 1 for success, 0 otherwise
-
move
public static int move(int xoff, int yoff)
move the mouse from the current position to the offset position given by the parameters- Parameters:
xoff
- horizontal offset (< 0 left, > 0 right)yoff
- vertical offset (< 0 up, > 0 down)- Returns:
- 1 for success, 0 otherwise
-
down
public static void down(int buttons)
press and hold the given buttonsButton
- Parameters:
buttons
- value
-
up
public static void up()
release all buttons
-
up
public static void up(int buttons)
release the given buttonsButton
- Parameters:
buttons
- (0 releases all buttons)
-
wheel
public static void wheel(int direction, int steps)
move mouse using mouse wheel in the given direction the given steps
the result is system dependent- Parameters:
direction
-Button
steps
- value
-
-