Generic sikuli logic if screen postion got changed

Asked by manas

Suppose i am writing the script for searching a particular text in a window. But if by mistake my window position got changed or window size got changed then my whole script will go for a toss. Is there any way to handle this situation.

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

I guess you are working with absolute Regions ( Region(x, y, w, h) ).

If your search area (in your case the window) might change position and/or size between scrip runs, you have to some how get the window are either based on the App class (see docs) or by searching a fixed key visual (logo, header, ...) from where you calculate the search area, e.g.

ref = find(key_visual)
window = Region(ref.x-50, ref.y-20, 600, 400)

more options like Region.left(), ... can be found in the docs.

Revision history for this message
j (j-the-k) said :
#2

If you follow RaiMans suggestion to search for one or more visual key elements from which you can determine the position of the window, you can pack this functionality into an observer and run it in the background so that it observes the logo/header of the window and recalculates the right window position everytime its location changes.

I would not recommend the App class because it often did not work as expected in my scripts.

If performance is not critical for you, you could also change the Region where you search your text to SCREEN, so the whole screen will be searched for the text, but this is a rather bad solution ;-)

Revision history for this message
manas (mandalmanas786) said :
#3

Thanks for your reply.

Can you help with this problem?

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

To post a message you must log in.