Region click + next point of region

Asked by supermaster

Hello everyone,

I've a bit of simple problem but its been way too long since i've stopped programming thought i'd better ask to get some help.

I am trying to do some region rightClick() and then just one line underneath want to click the spot underneath son in UI it would look like this.

Here is the little image that explains what i want to do...

http://imageshack.us/photo/my-images/215/boxclickproblem.png/

Any help would be highly appreciated :)
PS: the box isn't bigger than a normal keyboard button nor the drop down list more than 3 lines.

thanks in advance

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
supermaster (some14on) said :
#1
Revision history for this message
RaiMan (raimund-hocke) said :
#2

--- use navigation key (if possible)
this is always the easiest way with GUI elements:

rightClick("dropdown.png")
wait(0.5) # might be needed
type(Key.DOWN)
type(Key.ENTER)

--- use calculated regions
use any tool to measure pixels on the screen and construct regions/locations based on a fixed element, that can be found on the screen.

e.g.
ref = Region(find("dropdown.png"))
rightClick(ref)
wait(0.5) # might be needed
click(ref.below(30))

this will find the region of dropdown.png, right click and then click the center of the region below (same width - height(30))

Revision history for this message
supermaster (some14on) said :
#3

Hay RaiMan thanks for instant reply went through some of your epic work you are really doing awesome job here, almost every post has your reply here with an amazing answer and knowledge that you share would like to thank you for your every single effort and every one else who put this community together :)

1: the rightClick("dropdown.png") isn't recognized as it (Theimage of dorpdown.png") is in constant change and the Key.DOWN isn't operate able there nor recognizable so is there any formula or way i can create a formula or if you have one? to just move mouse two lines down and then click it with every right click along the shape? region to move along right click its regardless of its clicked location with rectangle or diagonal shape/size ?

I've tried both methods of yours both failed unfortunately thus only thing i can think is fixed region to move along the right click each time? or maybe you know better ways as i've been out of programming for quite long time!

many thanks once again and do appreciate ur hard work and awesome reply here :)
Regards

Revision history for this message
supermaster (some14on) said :
#4

just a small note:

The search for a matching pic is very slow is there any settings option where it can be set to look for a file/image/pattern more faster such as Settings.MoveMouseDelay = 0 ?

Thanks :)

Revision history for this message
supermaster (some14on) said :
#5

i dont know how many errors are there (professionally) as i've only got this much and there are not many errors but does work to extent.

    while dd < 28:
        rightClick (Region(X,Y,W,H))
        click (Region(X,Y+42,W,H))
        wait(.05)
        dd = dd + 1
        X = X + 42

        if (dd == 5):
            Y = 615 # to set 2nd row
            X = 910
        if (dd == 9):
            Y = 660 # to set 3nd row
            X = 910
        if (dd == 13):
            Y = 690 # to set 4 row
            X = 910
        if (dd == 17):
            Y = 720 # to set 5 row
            X = 910
        if (dd == 21):
            Y = 765 # to set 6 row
            X = 910
        if (dd == 25):
            Y = 800 # to set 6 row
            X = 910
            W = 5
            H = 5
        if (dd == 28):
            Y = 570 # to set 7 row
            X = 910

maybe anyone can make it professional :)

regards

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

to just click points on the screen, we have the Location objects, which just have x and y coordinates.

There are some Region methods, that return such points:
Region.getCenter()
Match.getTarget()
Region.getTopLeft()
...

and we have offset operators for Locations:

m = find("some image.png")
aPoint = m.getCenter()
click(aPoint.below(100))

would click 100 pixels below the center of the match region (in fact the region of the found image on the screen).

here is an example with the home page of amazon.com. there is a drop down in the top left, where you select the search category.

# find the amazon logo
# the click point (target offset) was evaluated using IDE's preview
m = find(Pattern("amazon.png").targetOffset(204,25))
# this clicks on the drop down
click(m)
# this is the reference point for the list
ref = m.getTarget()
# each entry has height 16
dd = 16
we hover over the first 5 entries
for i in range(5):
    hover(ref.below((i+1)*dd))
    wait(0.5)

# and this clicks the 10th entry
click(ref.below(10*dd))

you may download a running script at http://dl.dropbox.com/u/42895525/dropdown.sikuli.zip
just unzip, open amazon.com in a browser and run the script.

Can you help with this problem?

Provide an answer of your own, or ask supermaster for more information if necessary.

To post a message you must log in.