How to speed up script

Asked by Adam Sycko on 2018-04-02

Hello
Its my script
for step in range(99999):
    wait("1522495093423.png", 99999999999)
    click(Pattern("1522495093423.png").targetOffset(0,33))
    sleep(1.0)
    type("e")
    sleep(0.1)
    type("f")
    sleep(10.0)
    wait(Pattern("1522496447516.png").targetOffset(19,-189), 99999999)
    click(Pattern("1522496447516.png").targetOffset(19,-189))
    sleep(0.2)
What i can do to make sikuli use this script faster i mean faster findimage faster move mouse(best if teleport) and other things do faster. Can somone help me i will be grateful.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
2018-04-02
Last query:
2018-04-02
Last reply:
2018-04-02
masuo (masuo-ohara) said : #1

By restricting the search to a smaller region, you can speed up processing.

http://sikulix-2014.readthedocs.io/en/latest/region.html#finding-inside-a-region-and-waiting-for-a-visual-event

By using getLastMatch() to avoid a second search for the same image, you can speed up a little.

http://sikulix-2014.readthedocs.io/en/latest/region.html?highlight=getLastMatch#Region.getLastMatch

Adam Sycko (fflanker) said : #2

Ok, thanks i will read it and try but can i do something with mouse ?

Adam Sycko (fflanker) said : #4

Ok much thanks to you but i read whole http://sikulix-2014.readthedocs.io/en/latest/region.html#finding-inside-a-region-and-waiting-for-a-visual-event and i cant understand how i can do this. Can you explain me how i can implement this "smaller region" ?

Settings.MoveMouseDelay = 0
for step in range(99999):
    wait("1522690717340.png", 99999999999)
    click(getLastMatch())
    sleep(1.0)
    type("e")
    sleep(0.1)
    type("f")
    sleep(10.0)
    wait(Pattern("1522496447516.png").targetOffset(19,-189), 99999999)
    click(Pattern("1522496447516.png").targetOffset(19,-189))
    sleep(0.2)

masuo (masuo-ohara) said : #5

Settings.MoveMouseDelay = 0
r1 = Region(50,50,400,300) # Specify the region where the image may appear.
r2 = Region(100,500,200,100) # It is unnecessary If the region where both of image may appear is same.
for step in range(99999):
    r1.wait("1522690717340.png", 99999999999)
    r1.click()
    sleep(1.0)
    type("e")
    sleep(0.1)
    type("f")
    sleep(10.0)
    r2.wait(Pattern("1522496447516.png").targetOffset(19,-189), 99999999)
    r2.click()
    sleep(0.2)

Adam Sycko (fflanker) said : #6

Ok, ok last question r1 = Region(50,50,400,300) what means this numbers monitor have only x, y so how i can specife region

Best masuo (masuo-ohara) said : #7

Please read the document.
http://sikulix-2014.readthedocs.io/en/latest/region.html?#Region.Region

Use SikuliX IDE, and click "Region" icon in the ribbon of SikuliX IDE window.

Adam Sycko (fflanker) said : #8

Thanks masuo, that solved my question.