"If" and "Find" Pictures

Asked by Martin Ehlert on 2018-09-14

Hello guys i have a little Problem that i dont get working !

I have a list like:

Connor
Alexis
Martin
Google
Muster

behind the names are sometimes 1 of 4 different symbols.. .
I want Sikulix to search for one of the for images. and click on it...
When you click on it there comes a farm where i want sikulix to click all
existing pictures...
When no Picture of the 4 are existing.. siculi should click to the next page and search again..

How can i Programm this in sikulix... I tried and tried.. but it isnt working :(

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2018-09-14
Last reply:
2018-09-15
RaiMan (raimund-hocke) said : #1

paste your most promising trial

Martin Ehlert (tarmino) said : #2

ok.. i want sikulix to check if there is

1.) Pic 1 or Pic 2 or Pic 3 or Pic 4
     when Sikulix found one of them i want siku to click them
2.) when Sikulix clicked them i want sikulix to check if there is Pic 1 or Pic 2 or Pic 3 or Pic 4
     and then click till all Pictures away..

and i dont know how to write it as shortly as its possible^^

RaiMan (raimund-hocke) said : #3

# version 1.1.4

# capture the pictures:
# write picN = and use capture button
pic1 = "pic1.png"
pic2 = "pic2.png"
pic3 = "pic3.png"
pic4 = "pic4.png"

pictures = [pic1, pic2, pic3, pic4]

matches = findAnyList(pictures)
if len(matches) > 0:
    # when Sikulix found one of them i want siku to click them
    for match in matches: click(match)
    matches = findAnyList(pictures)
   # and then click till all Pictures away..
    while (len(matches) > 0):
        for match in matches: click(match)
        matches = findAnyList(pictures)

... if I understood right ;-)

Martin Ehlert (tarmino) said : #4

thank you mate.. i will try to realize it^^

Martin Ehlert (tarmino) said : #5

ich hab Probleme das umzusetzen da ich in Phyton und Sikulix noch nicht so fit bin.. wenn ich dich richtig verstanden habe habe ich das so umgesetzt jetzt:

pic1 = "pic1.png"
pic2 = "pic2.png"
pic3 = "pic3.png"
pic4 = "pic4.png"

pictures = [pic1, pic2, pic3, pic4]

matches = findAnyList(pictures)
if len(matches) > 0:
for match in matches: click(match)
matches = findAnyList(pictures)
while (len(matches) > 0):
for match in matches: click(match)
matches = findAnyList(pictures)

richtig ?

RaiMan (raimund-hocke) said : #6

Nein ;-)

die Scriptsprache ist Python und du musst dich schon ein bisschen in die Basics einarbeiten.
Tutorials im Internet zu Hauf.

Die Einrückungen sind ein wesentlicher Bestandteil von Python (Indent/Dedent) um Blöcke zu kennzeichnen.
.. war also alles so gemeint - inkl. der Kommentare

Dann musst du wenigstens einmal die SikuliX Docs querlesen um zu wissen, was wo steht.

... und dann musst du probieren, probieren ,...

Andere deinen Code schreiben lassen macht keinen Sinn (glaub mir - fast ein Jahrzehnt Erfahrung damit).
Bevor jemand anderes verstanden hat was du willst, bist du selbst schon fast fertig und hast was dabei gelernt.
Wenn irgendeine Kleinigkeit nicht funktioniert und du das Script nicht verstanden hast, hast du eh keine Chance.

... und das allerwichtigste: du musst wirklich verstanden haben wie SikuliX arbeitet.

Also beiß dich rein oder lass es lieber sein.

Bei speziellen Problemen kannst Dur hier immer Anregungen finden und Hilfe bekommen.
... aber von dir muss dann auch was kommen, was du schon probiert hast (snippets ;-)

Martin Ehlert (tarmino) said : #7
Martin Ehlert (tarmino) said : #8

ok.. i tried this...

#capturing pics

pic1 = exists(.png)
pic2 = exists(.png)
pic3 = exists(.png)
pic4 = exists(.png)

Pic1 = exists(.png)
Pic2 = exists(.png)
Pic3 = exists(.png)
Pic4 = exists(.png)

pictures = [pic1,pic2,pic3,pic4]
Pictures = [Pic1,Pic2,Pic3,Pic4]

if pictures:
    click (pictures)
    for x in findAll (pictures):
           click(Pictures)

first i defined pictures too search.. then i said to him that he has to look for "pictures" -> click them and then he should click all "Pictures" but he dont do it.. what did i made wrong ?
when i start it.. there are no mistakes from the programm.. but he doesnt find any pics... ?!
would be nice ti get lightet^^

RaiMan (raimund-hocke) said : #9

--- when i start it.. there are no mistakes from the programm..
I do not know, what your are doing, but running this in the IDE gets

[error] script [ Untitled ] stopped with error in line 1 at column 14
[error] SyntaxError ( "no viable alternative at input '.'", )

... which is apparently correct.

The "script" you pasted has some logical and syntactical errors, so I think, this is not, what you have in your IDE.

if pictures: # does not make sense
    click (pictures) # does not work - no allowed parameter and does not make sense
    for x in findAll (pictures):
           click(Pictures) # does not work - no allowed parameter

simply compare with my example from comment #3

RaiMan (raimund-hocke) said : #10

... und das allerwichtigste: du musst wirklich verstanden haben wie SikuliX arbeitet.

Martin Ehlert (tarmino) said : #11

ok``

Can you help with this problem?

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

To post a message you must log in.