scroll down until image is seen on screen

Asked by Marc Summers on 2018-04-17

There is a specific image that I need to find
but the distance to scroll to it changes every two weeks.
But the horizontal spacing is the same, at 7 wheel downs.
So what I want to do is have findAll look for the image
and if it does not find anything then scroll down
7 more. Keep doing this scroll down 7 until it
finds the image.
So what am I doing wrong here ?

        icons = findAll("1523914836809.png")
        if exists(icons):
            wheel(Location(661, 465),WHEEL_DOWN,7)
    except Exception:

[error] script [ 796_795_garmin_charts_ctrl_eu_ifr_tdd_nd ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\Users\marc.summers\Desktop.sikuli\796_795_garmin_charts_ctrl_eu_ifr_tdd_nd.sikuli\", line 12, in <module> icons = findAll("1523914836809.png") File "C:\Users\marc.summers\Desktop.sikuli\796_795_garmin_charts_ctrl_eu_ifr_tdd_nd.sikuli\", line 12, in <module> icons = findAll("1523914836809.png") Line 2469, in file
at org.sikuli.script.Region.findAll(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
org.sikuli.script.FindFailed: FindFailed: 1523914836809.png: (209x19) in S(0)[0,0 1920x1200] E:Y, T:3.0 Line 2469, in


Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Solved by:
Marc Summers
Last query:
Last reply:
Marc Summers (2aircraft) said : #1

sikuli 1.1.2

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

OS Version: 10.0.15063 N/A Build 1506

Maze (msx-n) said : #2

not sure if this will help you but it sounds like a similar task:

Marc Summers (2aircraft) said : #3

They said it could not be done,
this is how it is done:

found = 0
while(found == 0):
        for i in findAll("1524078692187.png"):
            if find("1524078692187.png"):
                found = 1
    except FindFailed:
        wheel(Location(600, 450),WHEEL_DOWN,7)

RaiMan (raimund-hocke) said : #4

not sure, who told you "it could not be done"

Your solution is a bit overkill and if the image is not found, it will loop forever.

this works in all cases and is fast.

max = 10 # how often to scroll max
while max > 0:
    if not exists("1524078692187.png", 0):
        max -= 1
        max = -1 # to show it is there
if max > -1:
    print "image not on page"
# image was found, we can proceed
found = getLastMatch() # here is the image

Marc Summers (2aircraft) said : #5

Hello RaiMan:

Thanks so much for your help. :)
It is much appreciated.

SikuliX "RULES!" :)