add xy to this script

Asked by MJ

This is my code i have tried everything, can't figure out syntax to add xy600x600 to 1300x900 coordinates to this line to make it faster

    if exists(Pattern("1469321512445.png").similar(0.50)) or exists(Pattern("1470143332576.png").similar(0.50)):

for n in range(1):
    if exists(Pattern("1469321512445.png").similar(0.50)) or exists(Pattern("1470143332576.png").similar(0.50)):
        click(Pattern("1469305690339.png").similar(0.90).targetOffset(-70,-9))
        type("v", KeyModifier.CTRL)
        type(Key.ENTER)
        type("s", KeyModifier.CTRL)
    else:
        click(Pattern("1469222076906-1.png").targetOffset(-647,497))
        click(Pattern("1469206576875.png").targetOffset(-7,0))
        wait(4.0)

Thanks so much

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

--- st1 step to get it faster: only one search
 if exists(Pattern("1469321512445.png").similar(0.50), 0) or exists(Pattern("1470143332576.png").similar(0.50), 0):

--- 2nd step to make it faster: restrict search region
 reg = Region(x, y, w, h) # use your specific values
 if reg.exists(Pattern("1469321512445.png").similar(0.50), 0) or reg.exists(Pattern("1470143332576.png").similar(0.50), 0):

Revision history for this message
MJ (mjpmgr) said :
#2

about 30% faster. What is the best program for calculating XY coordinates? Sorry for the stupid question in advance.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

You can use the SikuliX IDE:
- with button Region select a Region
- in Menu View toggle ShowThumbnail

you will see something like
Region(123, 456, 78, 9)

there you have your coordinates.

Hope you are using version 1.1.1 which has some more helpful buttons.

Can you help with this problem?

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

To post a message you must log in.