← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #138964]: update FAQ #1110 for Sikuli X

 

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

RaiMan posted a new comment:
This was a "quick and dirty" example, but the principle is, that you get
new regions by combining an existing regions x,y,w,h with values you
have measured or guessed or by using the spatial operators like right,
below, ...

to mesure/guess I use either the IDE preview -> target offset feature or
the Mac screenshot tool which shows coordinates.

I have defined some helper functions that I import to get e.g. the
region inside another region below some visual object ...

so in the example above, to get the text from title bar of the FF
window, I could have written:

titleBar = regWinFox.above(1).below(25)

this gives me the whole titlebar. For text reading this is not optimal, because of the grafics left and right.
so lets make a def:
regInside(reg, left, right, top=0, bottom=0):
   return Region(reg.x+left, reg.y+top, reg.w-left-right, reg.h-top-bottom)

I decided, that the usage might be more often to ignore left and right,
so I set the default of top and bottom to 0, so in the standard usage
with text() I can leave them.

now we can get the text out of the titlebar
# has to be adjusted to your situation (once - forever ;-)
winTitleBarHeight = 25
winTitleBarIgnoreLeft = 25
winTitleBarIgnoreRight = 100

titleBar = regWinFox.above(1).below(winTitleBarHeight)
TitleBarText = regInside(titleBar, winTitleBarIgnoreLeft, winTitleBarIgnoreRight).text()

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