← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #205187]: combination on keypad

 

Question #205187 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/205187

    Status: Open => Answered

RaiMan proposed the following answer:
--- type
The examples in the doc tell you:
type("w", KeyModifier.CTRL) # lowercase w !

--- blue letters problem
this is not possible to solve with Sikuli using image search, since I guess, that the text in the marked column changes.
This a typical "click through a table column" problem, that can normally only be solved by clicking an calculated points on the screen.
You somehow have to find out the uppermost click position (first line) and the click the next ones using an offset to the fist one.
If you tell me, how I can get this live on my screen, I can give you more tips and samples.

--- green buttons
this could be solved the same way, since it is also a regular geometric GUI pattern.
But in this case you could use findAll().
And it is exactly the approach as mentioned at
http://sikuli.org/docx/region.html#Region.findAll

buttons = findAll("imageOfGreenButton.png")
sorted_buttons = sorted(buttons, key=lambda m: m.y*10000+m.x)
for button in sorted_buttons:
    button.highlight(1)

This will (hopefully ;-) find all green buttons and click them in the
order from left-to-right/top-to-bottom

or if you only want to click the first 3:
for i in range(3):
    sorted_buttons[i].highlight(1)

--- is that how you do it with region?
not really.
A region is an area with a fixed position and size on the screen.
You can only use it to click on it, if you are sure, that the region is always at the same position:

reg = Region(x,y,w,h) # you might have defined it with the above mentioned RegionButton
click(reg) # would click the center of the region

Regions are usually used, to restrict the search area for speed and
accuracy.

example with your first shot:

top = "FeaturedListing.png"
mTop = find(top)
mTop.highlight(1)
bottom = "FollowUs.png"
mBottom = find(bottom)
mBottom.highlight(1)
area = Region(mTop.x, mTop.y+mTop.h, mTop.w, mBottom.y-mTop.y-mTop.h)
area = area.nearby(10) # to add some margin
area.highlight(1)
# combined with the findAll() example
buttons = area.findAll("Button10.png")
sorted_buttons = sorted(buttons, key=lambda m: m.y*10000+m.x)
for button in sorted_buttons:
    button.highlight(1)

Hope it helps;-)

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.