← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #162592]: How to Copy text from a regions?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- Sikuli's OCR
If you want a reliable text copy feature: it is not usable currently.

--- type(Key.SHIFT+Key.DOWN)
this will never work, since in the combination shift-down, the shift is not a single key press, it is a modifier key, that goes together with the down key.

for these key combos you have to write:
type(Key.DOWN, KEY_SHIFT)

--- selecting text with mouse/keyboard actions
that is principally possible, but depends on the application.
In web pages, you usually have to select with the mouse.
In editor apps or editable sections in web pages clicking and then use keyboard actions usually works.

The challenge always is, to find e.g. the start point for the mouse
selection and to know where to move the mouse.

So again an example for this page:

Suppose, we have a pixel location, that is left of the first character
of the headline, then press and hold left button and move the mouse to
the right side until right of the last character, release the mouse and
fire a ctrl-v.

dir = "http://its-me-raiman.de/sikuli/images/";
sik = dir+"sikuli-logo-lp.png"
m=find(sik).below(42).left(1).right(600)
m.highlight(3)
leftPoint = m.getTopLeft().below(m.h/2)
rightPoint = m.getTopRight().below(m.h/2)
click(leftPoint)
keyDown(Key.SHIFT)
mouseDown(Button.LEFT)
hover(rightPoint)
mouseUp()
keyUp()
type("c", KEY_CTRL)
click(leftPoint) # to reset the selection
wait(3) # only to have a chance to see what happens
print Env.getClipboard()

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