org.sikuli.script
Class Region

java.lang.Object
  extended by org.sikuli.script.Region
Direct Known Subclasses:
Match, Screen

public class Region
extends Object


Field Summary
protected  double _autoWaitTimeout
           
protected  FindFailedResponse _defaultFindFailedResponse
           
protected  EventManager _evtMgr
           
protected  Match _lastMatch
           
protected  Iterator<Match> _lastMatches
           
protected  ScreenImage _lastScreenImage
           
protected  boolean _observing
           
protected  boolean _throwException
           
 int h
           
 int w
           
 int x
           
 int y
           
 
Constructor Summary
protected Region()
           
  Region(int x_, int y_, int w_, int h_)
          Deprecated. Not for public use in Java. Use Region.create() instead.
  Region(Rectangle r)
          Deprecated. Not for public use in Java. Use Region.create() instead.
  Region(Region r)
          Deprecated. Not for public use in Java. Use Region.create() instead.
 
Method Summary
 Region above()
           
 Region above(int range)
           
 Region below()
           
 Region below(int range)
           
<PSRML> int
click(PSRML target)
          Click on the item provided by "target"
<PSRML> int
click(PSRML target, int modifiers)
          Click on the item provided by "target"
static Region create(int x_, int y_, int w_, int h_)
          Create a region with the provided coordinate / size
static Region create(Rectangle rect)
          Create a region from a Rectangle
static Region create(Rectangle r, IScreen parentScreen)
           
static Region create(Region r)
          Create a region from an other region
<PSRML> int
doubleClick(PSRML target)
          Double click on the item provided by "target"
<PSRML> int
doubleClick(PSRML target, int modifiers)
          Double click on the item provided by "target"
<PSRML> int
drag(PSRML target)
           
<PSRML> int
dragDrop(PSRML t1, PSRML t2)
          Drag and drop from a position to the other
<PSRML> int
dragDrop(PSRML t1, PSRML t2, int modifiers)
          Drag and drop from a position to the other
<PSRML> int
dropAt(PSRML target)
           
<PSRML> int
dropAt(PSRML target, double delay)
           
<PSC> Match
exists(PSC target)
          Check if target exists (with the default autoWaitTimeout)
<PSC> Match
exists(PSC target, double timeout)
          Check if target exists with a specified timeout
<PSC> Match
find(PSC target)
          Match find( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match.
<PSC> Iterator<Match>
findAll(PSC target)
          Iterator findAll( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match.
<PSC> Iterator<Match>
findAllNow(PSC ptn)
          Match findAllNow( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match without waiting.
<PSC> Match
findNow(PSC ptn)
          Match findNow( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match without waiting.
 double getAutoWaitTimeout()
           
 Location getBottomLeft()
           
 Location getBottomRight()
           
 Location getCenter()
           
protected  EventManager getEventManager()
           
 FindFailedResponse getFindFailedResponse()
           
 int getH()
           
 Match getLastMatch()
           
 Iterator<Match> getLastMatches()
           
<PSRML> Location
getLocationFromPSRML(PSRML target)
          Figure out where is located target
 Rectangle getRect()
           
<PSRM> Region
getRegionFromPSRM(PSRM target)
          Figure out where is located target
 Rectangle getROI()
           
 IScreen getScreen()
           
 boolean getThrowException()
           
 Location getTopLeft()
           
 Location getTopRight()
           
 int getW()
           
 int getX()
           
 int getY()
           
 void highlight()
           
protected  void highlight(boolean toEnable)
           
 void highlight(float secs)
           
<PSRML> int
hover(PSRML target)
           
protected  void init(int x_, int y_, int w_, int h_, IScreen parentScreen)
           
 Region inside()
           
 void keyDown(int keycode)
          press down the key (given by the key code) on the underlying device.
 void keyDown(String keys)
           
 void keyUp()
           
 void keyUp(int keycode)
          release the key (given by the key code) on the underlying device.
 void keyUp(String keys)
           
 Region left()
           
 Region left(int range)
           
 List<Match> listText()
           
 Region morphTo(Region r)
           
 void mouseDown(int buttons)
           
<PSRML> int
mouseMove(PSRML target)
           
 void mouseUp()
           
 void mouseUp(int buttons)
           
 Region moveTo(Location loc)
           
 Region nearby()
           
 Region nearby(int range)
           
 void observe()
           
 void observe(double secs)
           
 void observeInBackground(double secs)
           
 Region offset(Location loc)
           
<PSC> void
onAppear(PSC target, SikuliEventObserver observer)
           
 void onChange(int threshold, SikuliEventObserver observer)
           
 void onChange(SikuliEventObserver observer)
           
<PSC> void
onVanish(PSC target, SikuliEventObserver observer)
           
<PSRML> int
paste(PSRML target, String text)
           
 int paste(String text)
           
 Region right()
           
 Region right(int range)
           
<PSRML> int
rightClick(PSRML target)
          Right click on the item provided by "target"
<PSRML> int
rightClick(PSRML target, int modifiers)
          Right click on the item provided by "target"
 void setAutoWaitTimeout(double sec)
           
 void setFindFailedResponse(FindFailedResponse res)
           
 void setH(int _h)
           
 void setRect(int X, int Y, int W, int H)
           
 void setRect(Rectangle roi)
           
 void setRect(Region roi)
           
 void setROI(int X, int Y, int W, int H)
           
 void setROI(Rectangle roi)
           
 void setROI(Region roi)
           
 void setThrowException(boolean flag)
           
 void setW(int _w)
           
 void setX(int _x)
           
 void setY(int _y)
           
 void stopObserver()
           
 String text()
           
static Region toJythonRegion(Region r)
           
 String toString()
           
<PSRML> int
type(PSRML target, String text)
           
<PSRML> int
type(PSRML target, String text, int modifiers)
           
<PSRML> int
type(String text)
           
<PSRML> int
type(String text, int modifiers)
           
protected  void updateSelf()
           
 void wait(double timeout)
           
<PSC> Match
wait(PSC target)
           
<PSC> Match
wait(PSC target, double timeout)
          Match wait(Pattern/String/PatternClass target, timeout-sec) waits until target appears or timeout (in second) is passed
<PSC> Iterator<Match>
waitAll(PSC target, double timeout)
          Deprecated. 
<PSC> boolean
waitVanish(PSC target)
           
<PSC> boolean
waitVanish(PSC target, double timeout)
          boolean waitVanish(Pattern/String/PatternClass target, timeout-sec) waits until target vanishes or timeout (in second) is passed
 int wheel(int direction, int steps)
          Move the wheel at the current position
<PSRML> int
wheel(PSRML target, int direction, int steps)
          Move the wheel at the specified position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

w

public int w

h

public int h

_defaultFindFailedResponse

protected FindFailedResponse _defaultFindFailedResponse

_throwException

protected boolean _throwException

_autoWaitTimeout

protected double _autoWaitTimeout

_observing

protected boolean _observing

_evtMgr

protected EventManager _evtMgr

_lastScreenImage

protected ScreenImage _lastScreenImage

_lastMatch

protected Match _lastMatch

_lastMatches

protected Iterator<Match> _lastMatches
Constructor Detail

Region

@Deprecated
public Region(int x_,
                         int y_,
                         int w_,
                         int h_)
Deprecated. Not for public use in Java. Use Region.create() instead.

Create a region with the provided coordinate / size

Parameters:
x_ - X position
y_ - Y position
w_ - width
h_ - heigth

Region

@Deprecated
public Region(Rectangle r)
Deprecated. Not for public use in Java. Use Region.create() instead.

Create a region from a Rectangle

Parameters:
r - the Rectangle

Region

@Deprecated
public Region(Region r)
Deprecated. Not for public use in Java. Use Region.create() instead.

Create a region from an other region

Parameters:
r - the region

Region

protected Region()
Method Detail

setFindFailedResponse

public void setFindFailedResponse(FindFailedResponse res)

getFindFailedResponse

public FindFailedResponse getFindFailedResponse()

create

public static Region create(Rectangle rect)
Create a region from a Rectangle

Parameters:
r - the Rectangle

create

public static Region create(int x_,
                            int y_,
                            int w_,
                            int h_)
Create a region with the provided coordinate / size

Parameters:
x_ - X position
y_ - Y position
w_ - width
h_ - heigth

create

public static Region create(Rectangle r,
                            IScreen parentScreen)

create

public static Region create(Region r)
Create a region from an other region

Parameters:
r - the region

toString

public String toString()
Overrides:
toString in class Object

init

protected void init(int x_,
                    int y_,
                    int w_,
                    int h_,
                    IScreen parentScreen)

getEventManager

protected EventManager getEventManager()

updateSelf

protected void updateSelf()

getScreen

public IScreen getScreen()

getX

public int getX()

getY

public int getY()

getW

public int getW()

getH

public int getH()

setX

public void setX(int _x)

setY

public void setY(int _y)

setW

public void setW(int _w)

setH

public void setH(int _h)

getROI

public Rectangle getROI()

setROI

public void setROI(int X,
                   int Y,
                   int W,
                   int H)

setROI

public void setROI(Region roi)

setROI

public void setROI(Rectangle roi)

highlight

public void highlight()

highlight

protected void highlight(boolean toEnable)

highlight

public void highlight(float secs)

getRect

public Rectangle getRect()

setRect

public void setRect(Rectangle roi)

setRect

public void setRect(int X,
                    int Y,
                    int W,
                    int H)

setRect

public void setRect(Region roi)

getCenter

public Location getCenter()

getTopLeft

public Location getTopLeft()

getTopRight

public Location getTopRight()

getBottomLeft

public Location getBottomLeft()

getBottomRight

public Location getBottomRight()

offset

public Region offset(Location loc)

moveTo

public Region moveTo(Location loc)

morphTo

public Region morphTo(Region r)

nearby

public Region nearby()

nearby

public Region nearby(int range)

right

public Region right()

right

public Region right(int range)

left

public Region left()

left

public Region left(int range)

above

public Region above()

above

public Region above(int range)

below

public Region below()

below

public Region below(int range)

inside

public Region inside()

setThrowException

public void setThrowException(boolean flag)

setAutoWaitTimeout

public void setAutoWaitTimeout(double sec)

getThrowException

public boolean getThrowException()

getAutoWaitTimeout

public double getAutoWaitTimeout()

find

public <PSC> Match find(PSC target)
           throws FindFailed
Match find( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match. If AutoWaitTimeout is set, this is equivalent to wait().

Parameters:
target - A search criteria
Returns:
If found, the element. null otherwise
Throws:
FindFailed - if the Find operation failed

findAll

public <PSC> Iterator<Match> findAll(PSC target)
                        throws FindFailed
Iterator findAll( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match. If AutoWaitTimeout is set, this is equivalent to wait().

Parameters:
target - A search criteria
Returns:
All elements matching
Throws:
FindFailed - if the Find operation failed

wait

public void wait(double timeout)

wait

public <PSC> Match wait(PSC target)
           throws FindFailed
Throws:
FindFailed

wait

public <PSC> Match wait(PSC target,
                        double timeout)
           throws FindFailed
Match wait(Pattern/String/PatternClass target, timeout-sec) waits until target appears or timeout (in second) is passed

Parameters:
target - A search criteria
timeout - Timeout in seconds
Returns:
All elements matching
Throws:
FindFailed - if the Find operation failed

exists

public <PSC> Match exists(PSC target)
Check if target exists (with the default autoWaitTimeout)

Parameters:
target - A search criteria
Returns:
The element matching

exists

public <PSC> Match exists(PSC target,
                          double timeout)
Check if target exists with a specified timeout

Parameters:
target - A search criteria
timeout - Timeout in second
Returns:
The element matching

waitVanish

public <PSC> boolean waitVanish(PSC target)

waitVanish

public <PSC> boolean waitVanish(PSC target,
                                double timeout)
boolean waitVanish(Pattern/String/PatternClass target, timeout-sec) waits until target vanishes or timeout (in second) is passed

Returns:
true if the target vanishes, otherwise returns false.

click

public <PSRML> int click(PSRML target)
          throws FindFailed
Click on the item provided by "target"

Parameters:
target - Where to click
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

click

public <PSRML> int click(PSRML target,
                         int modifiers)
          throws FindFailed
Click on the item provided by "target"

Parameters:
target - Where to click
modifiers - Can be 0 (no modifier), K_SHIFT, K_CTRL, K_ALT or K_META
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

doubleClick

public <PSRML> int doubleClick(PSRML target)
                throws FindFailed
Double click on the item provided by "target"

Parameters:
target - Where to double click
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

doubleClick

public <PSRML> int doubleClick(PSRML target,
                               int modifiers)
                throws FindFailed
Double click on the item provided by "target"

Parameters:
target - Where to double click
modifiers - Can be 0 (no modifier), K_SHIFT, K_CTRL, K_ALT or K_META
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

rightClick

public <PSRML> int rightClick(PSRML target)
               throws FindFailed
Right click on the item provided by "target"

Parameters:
target - Where to right click
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

rightClick

public <PSRML> int rightClick(PSRML target,
                              int modifiers)
               throws FindFailed
Right click on the item provided by "target"

Parameters:
target - Where to right click
modifiers - Can be 0 (no modifier), K_SHIFT, K_CTRL, K_ALT or K_META
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

wheel

public int wheel(int direction,
                 int steps)
          throws FindFailed
Move the wheel at the current position

Parameters:
direction - the direction applied
steps - the number of step
Returns:
1 in any case
Throws:
FindFailed

wheel

public <PSRML> int wheel(PSRML target,
                         int direction,
                         int steps)
          throws FindFailed
Move the wheel at the specified position

Parameters:
target - The specified position
direction - the direction applied
steps - the number of step
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

mouseMove

public <PSRML> int mouseMove(PSRML target)
              throws FindFailed
Throws:
FindFailed

hover

public <PSRML> int hover(PSRML target)
          throws FindFailed
Throws:
FindFailed

dragDrop

public <PSRML> int dragDrop(PSRML t1,
                            PSRML t2)
             throws FindFailed
Drag and drop from a position to the other

Parameters:
t1 - The specified source position
t2 - The specified destination position
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

dragDrop

public <PSRML> int dragDrop(PSRML t1,
                            PSRML t2,
                            int modifiers)
             throws FindFailed
Drag and drop from a position to the other

Parameters:
t1 - The specified source position
t2 - The specified destination position
modifiers - Can be 0 (no modifier), K_SHIFT, K_CTRL, K_ALT or K_META
Returns:
1 if success, 0 otherwise
Throws:
FindFailed - if the Find operation failed

drag

public <PSRML> int drag(PSRML target)
         throws FindFailed
Throws:
FindFailed

dropAt

public <PSRML> int dropAt(PSRML target)
           throws FindFailed
Throws:
FindFailed

dropAt

public <PSRML> int dropAt(PSRML target,
                          double delay)
           throws FindFailed
Throws:
FindFailed

type

public <PSRML> int type(String text)
         throws FindFailed
Throws:
FindFailed

type

public <PSRML> int type(String text,
                        int modifiers)
         throws FindFailed
Throws:
FindFailed

type

public <PSRML> int type(PSRML target,
                        String text)
         throws FindFailed
Throws:
FindFailed

type

public <PSRML> int type(PSRML target,
                        String text,
                        int modifiers)
         throws FindFailed
Throws:
FindFailed

paste

public int paste(String text)
          throws FindFailed
Throws:
FindFailed

paste

public <PSRML> int paste(PSRML target,
                         String text)
          throws FindFailed
Throws:
FindFailed

mouseDown

public void mouseDown(int buttons)

mouseUp

public void mouseUp()

mouseUp

public void mouseUp(int buttons)

keyDown

public void keyDown(int keycode)
press down the key (given by the key code) on the underlying device. The code depend on the type of the device.


keyUp

public void keyUp(int keycode)
release the key (given by the key code) on the underlying device. The code depend on the type of the device.


keyDown

public void keyDown(String keys)

keyUp

public void keyUp()

keyUp

public void keyUp(String keys)

onAppear

public <PSC> void onAppear(PSC target,
                           SikuliEventObserver observer)

onVanish

public <PSC> void onVanish(PSC target,
                           SikuliEventObserver observer)

onChange

public void onChange(int threshold,
                     SikuliEventObserver observer)

onChange

public void onChange(SikuliEventObserver observer)

observe

public void observe()

observeInBackground

public void observeInBackground(double secs)

stopObserver

public void stopObserver()

observe

public void observe(double secs)

getLastMatch

public Match getLastMatch()

getLastMatches

public Iterator<Match> getLastMatches()

text

public String text()

listText

public List<Match> listText()

toJythonRegion

public static Region toJythonRegion(Region r)

findNow

public <PSC> Match findNow(PSC ptn)
              throws FindFailed
Match findNow( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match without waiting.

Throws:
FindFailed

findAllNow

public <PSC> Iterator<Match> findAllNow(PSC ptn)
                           throws FindFailed
Match findAllNow( Pattern/String/PatternClass ) finds the given pattern on the screen and returns the best match without waiting.

Throws:
FindFailed

waitAll

@Deprecated
public <PSC> Iterator<Match> waitAll(PSC target,
                                                double timeout)
                        throws FindFailed
Deprecated. 

Iterator waitAll(Pattern/String/PatternClass target, timeout-sec) waits until target appears or timeout (in second) is passed

Throws:
FindFailed

getRegionFromPSRM

public <PSRM> Region getRegionFromPSRM(PSRM target)
                         throws FindFailed
Figure out where is located target

Parameters:
target - The specified position
Returns:
The Region if found. null otherwise.
Throws:
FindFailed

getLocationFromPSRML

public <PSRML> Location getLocationFromPSRML(PSRML target)
                              throws FindFailed
Figure out where is located target

Parameters:
target - The specified position
Returns:
The Location if found. null otherwise.
Throws:
FindFailed