Package org.sikuli.script.runnerSupport
Class JavaScriptSupport
java.lang.Object
org.sikuli.script.runnerSupport.JavaScriptSupport
- All Implemented Interfaces:
IRunnerSupport
public class JavaScriptSupport extends Object implements IRunnerSupport
EXPERIMENTAL --- INTERNAL USE ONLY
is not official API --- will not be in version 2
is not official API --- will not be in version 2
-
Constructor Summary
Constructors Constructor Description JavaScriptSupport() -
Method Summary
Modifier and Type Method Description static Objectcall(String function, Object... args)INTERNAL USE: call interface for JavaScript to be used with predefined functionsstatic Objectcircle(Object args)static Locationclick(Object... args)move the mouse with hover() and click using the left buttonstatic LocationdoubleClick(Object... args)move the mouse with hover() and double click using the left buttonstatic Matchexists(Object... args)wait for the given visual to appear within the given wait timestatic ObjectfromJSON(Object aObj)experimental: create the real object from the given JSON
take care: content length not checked if valid (risk for index out of bounds)
planned to be used with a socket/RPC based interface to any framework (e.g.static Locationhover(Object... args)move the mouse to the given location with a given offset
3 parameter configurations:
--1: wait for a visual and move mouse to it (args see wait())
--2: move to the given region/location/match with a given offset
--3: move to the given offset relative to the last match of the region in usestatic booleanisJSON(Object aObj)check wether the given object is in JSON format as ["ID", ...]static booleanisNashorn()static booleanpaste(Object... args)just doing a currentRegion.paste(text) (see paste())static voidrestoreUsed()INTERNAL USE: restore a saved use() after a use1()static LocationrightClick(Object... args)move the mouse with hover() and do a right clickstatic Objectrun(Object... args)booleanrunObserveCallback(Object[] args)Run callback for observers.static Regionuse(Object... args)all following undotted function calls will use the given screen or region until this is changed by a later use()
-- no args: use Screen(0) (this is the default after start)
-- a number: use Screen(number), Screen(0) if not valid
-- a region: use the given regionstatic Regionuse1(Object... args)same as use(), but only affects the next processed undotted function after that the use() active before is restoredstatic Matchwait(Object... args)wait for the given visual to appear within the given wait time
args [String|Pattern|Double, [Double, [Float]]] (max 3 args)
arg1: String/Pattern to search or double time to wait (rest ignored)
arg2: time to wait in seconds
arg3: minimum similarity to use for search (overwrites Pattern setting)static booleanwaitVanish(Object... args)wait for the given visual to vanish within the given wait timestatic booleanwrite(Object... args)just doing a currentRegion.write(text) (see write())
-
Constructor Details
-
JavaScriptSupport
public JavaScriptSupport()
-
-
Method Details
-
isNashorn
public static boolean isNashorn()- Returns:
- true if we are on Java 8+
-
call
INTERNAL USE: call interface for JavaScript to be used with predefined functions- Parameters:
function- the function's nameargs- the parameters- Returns:
- the object returned by the function or null
-
run
-
circle
-
use
all following undotted function calls will use the given screen or region until this is changed by a later use()
-- no args: use Screen(0) (this is the default after start)
-- a number: use Screen(number), Screen(0) if not valid
-- a region: use the given region- Parameters:
args-- Returns:
- the used region
-
use1
same as use(), but only affects the next processed undotted function after that the use() active before is restored- Parameters:
args- see use()- Returns:
- the used region
-
restoreUsed
public static void restoreUsed()INTERNAL USE: restore a saved use() after a use1() -
wait
wait for the given visual to appear within the given wait time
args [String|Pattern|Double, [Double, [Float]]] (max 3 args)
arg1: String/Pattern to search or double time to wait (rest ignored)
arg2: time to wait in seconds
arg3: minimum similarity to use for search (overwrites Pattern setting)- Parameters:
args-- Returns:
- the match or throws FindFailed
- Throws:
FindFailed
-
waitVanish
wait for the given visual to vanish within the given wait time- Parameters:
args- see wait()- Returns:
- true if not there from beginning or vanished within wait time, false otherwise
-
exists
wait for the given visual to appear within the given wait time- Parameters:
args- see wait()- Returns:
- the match or null if not found within wait time (no FindFailed exception)
-
hover
move the mouse to the given location with a given offset
3 parameter configurations:
--1: wait for a visual and move mouse to it (args see wait())
--2: move to the given region/location/match with a given offset
--3: move to the given offset relative to the last match of the region in use- Parameters:
args-- Returns:
- the evaluated location to where the mouse should have moved
-
click
move the mouse with hover() and click using the left button- Parameters:
args- see hover()- Returns:
- the location, where the click was done
-
doubleClick
move the mouse with hover() and double click using the left button- Parameters:
args- see hover()- Returns:
- the location, where the double click was done
-
rightClick
move the mouse with hover() and do a right click- Parameters:
args- see hover()- Returns:
- the location, where the right click was done
-
paste
just doing a currentRegion.paste(text) (see paste())- Parameters:
args- only one parameter being a String- Returns:
- true if paste() returned 1, false otherwise
-
write
just doing a currentRegion.write(text) (see write())- Parameters:
args- only one parameter being a String- Returns:
- true if write() returned 1, false otherwise
-
isJSON
check wether the given object is in JSON format as ["ID", ...]- Parameters:
aObj-- Returns:
- true if object is in JSON format, false otherwise
-
fromJSON
experimental: create the real object from the given JSON
take care: content length not checked if valid (risk for index out of bounds)
planned to be used with a socket/RPC based interface to any framework (e.g. C#) Region ["R", x, y, w, h]
Location ["L", x, y]
Match ["M", x, y, w, h, score, offx, offy]
Screen ["S", x, y, w, h, id]
Pattern ["P", "imagename", score, offx, offy]
These real objects have a toJSON(), that returns these JSONs- Parameters:
aObj-- Returns:
- the real object or the given object if it is not one of these JSONs
-
runObserveCallback
Description copied from interface:IRunnerSupportRun callback for observers.- Specified by:
runObserveCallbackin interfaceIRunnerSupport- Parameters:
args- is array for two elements. First is a callback object. Second is an event.- Returns:
- true if the callback was ran correctly. False in other cases.
-