get and then set text in specific region

Asked by lazar

1. get text in specific region (with jython ?)
 how I get text from a region ?
 if the text is in foreign language , how sikuli manage it ?
 can I give to textGet function language param's ?

any code sample can help

2. how I set new text on some input field,
  how sikuli can recognize a region as input field ?
  how to locate the coordinate of a curser so it will start from beginning of
  input filed ?
 any code sample or linkTo will help

3. coordinate relative to form
  has the coordinate a parameter so it will be relative to form ? and not absolute to screen ?
 (just in case the form 'move' a little)

3. OCR confidence
   are sikulli using some screen "grab" rasterize, that wiil give more ocr power, or just
  "standard" ocr , tesseract ?
  on most screen applications the developer know's the font usage ,
  can I "help" sikuli ocr about font/size/type to make ocr more accurate ?

lazar

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
RaiMan (raimund-hocke) said :
#1

--- OCR / getText from Region
the currently (rc2) available Region.text() is based on tesseract and still experimental. It is neither reliable nor flexible nor configurable (bug 710586). They work on an optimized version for rc3 (I do not know the status).
If you want to contribute in any aspect, contact Sean (Tsung-Hsiang Chang <email address hidden>) directly.

--- relative coordinates
all find and action commands are relative to a given region. If you use them without a region like find(), click(), ... they operate on the standard region SCREEN, which is a constant reference to Screen(0) (you can find more in the docs).
so you either say reg.find() to restrict to the region reg or use the with reg: construct, which redirects all unqualified functions inside the block to reg.

--- set new text in input field
many people use a find() operation with an image having target offset, to locate an input field and click on the target offset to give focus to the input field. normally this ends up in the current content to be selected. Then you use type() or paste() to fill in text and hit enter or tab.
For fixed layouts I prefer to only find one fixed spot of the dialog window and then use calculated/measured offsets to click (give focus to) the input fields. In many cases you can use tab to step through the fields.

--- recognize input fields
Sikuli has no feature to recognize anything by GUI element type - only image and text search to define a pixel location on the screen to act on. The script workflow designer has to have this knowledge and translate it to Sikuli scripting as matching images.
There is one exception: the App class is able to return the app windows as regions (some restrictions apply - look docs).

Can you help with this problem?

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

To post a message you must log in.