getRegionFromPSRM()

Asked by emrah kara

Hello,

i downloaded the new Sikuli, the 1.0.1. and try it on java.

my question ist where is the methode screen.getRegionFromPSRM() ?

is there a smilar one in new jar file that i can use?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- screen.getRegionFromPSRM()

Since I never understood the value behind this method, I set it to private and renamed it to

Are you able to tell me, what it is worth for?

This is the source code:
  private <PSRM> Region getRegionFromTarget(PSRM target) throws FindFailed {
    if (target instanceof Pattern || target instanceof String) {
      Match m = find(target);
      if (m != null) {
        return m;
      }
      return null;
    }
    if (target instanceof Region) {
      return (Region) target;
    }
    return null;
  }

Revision history for this message
emrah kara (emrah-karakoc) said :
#2

Thank you for the source code :)

it need it, to find the right button to click if there is more than 1 same picture on the screen.

for example, there is 3 close browser buttons on the screen and i want a spesific one. getRegionFromPSRM helps me to search the button in a special region.

screen.getRegionFromPSRM("something.png").click("closeBrowser.png");

Revision history for this message
emrah kara (emrah-karakoc) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

This exactly, why I never understood why this is needed:

screen.find("something.png").click("closeBrowser.png");

Revision history for this message
emrah kara (emrah-karakoc) said :
#5

what is actually find(target); ?
is there a methode in the same class? or with which object should i call the find() methode?
what does it actually do? could i have the cource code of it also :)?

Revision history for this message
emrah kara (emrah-karakoc) said :
#6

for example i want to click on the "RaiMan" in this topic, which we discuss about..
i want to click on: http://www.myimg.de/?img=Bildschirmfoto20130920u52fca.png

but as you see, there is 2 RaiMan on the screen: http://www.myimg.de/?img=Bildschirmfoto20130920u776db.png

that is why i say screen.getRegionFromPSRM(http://www.myimg.de/?img=Bildschirmfoto20130920u5c224.png).click(http://www.myimg.de/?img=Bildschirmfoto20130920u52fca.png);

Revision history for this message
RaiMan (raimund-hocke) said :
#7

Uuups, you seem not to be aware of some basic features of Sikuli:

click(Pattern(http://www.myimg.de/?img=Bildschirmfoto20130920u5c224.png).targetOffset(-100,0))

find() (used e.g. in getRegionFromPSRM if target is an image file), wait() and exists() are the basic search functions in Sikuli, to get the region taken by a found image (returned is a Match object, that is a subclass of Region)

Revision history for this message
Best RaiMan (raimund-hocke) said :
#8

... and we have findAll() to find all occurences of an image in a given region.

Revision history for this message
emrah kara (emrah-karakoc) said :
#9

Thanks RaiMan, that solved my question.