multiple selection

Asked by hakim johari

Hi I need to select random and multiple list.
I've got the random part but how do I select multiple list?

this is my script

lineH = 31
top = find(Pattern(Pattern("some_pic.png").targetOffset(0,18)))
topP = top.getTarget()
lineNbr = random.randint(0, 30)
click(topP.below(lineNbr * lineH))

this only select 1 list
I want to select 5 list.

Thanks

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

the flexible part of the code (specific for the list):

top = find(Pattern(Pattern("some_pic.png").targetOffset(0,18)))

the fixed part of code (valid for each list)

topP = top.getTarget()
lineNbr = random.randint(0, 30)
click(topP.below(lineNbr * lineH))

so we put the fixed stuff in a def():

def clickList(top):
    topP = top.getTarget()
    lineNbr = random.randint(0, 30)
    click(topP.below(lineNbr * lineH))

and use it this way:

top1 = find(Pattern("some_pic.png").targetOffset(0,18)) # ref for list 1
clickList(top1)

top2 = find(Pattern("some_other_pic.png").targetOffset(0,18)))# ref for list 2, may be different targetOffset
clickList(top2)

... I guess you got it ;-)

Revision history for this message
hakim johari (hakim-johari) said :
#2

wouldn't this be like click A then click B right?

what I need to do is press CTRL button then without letting go of CTRL button, click a + click b + click c

CTRL + click a + click b + click c

so i can select 3 list at once.

can you help me?

many thanks.

Revision history for this message
hakim johari (hakim-johari) said :
#3

i tried to use this script

top1 = find(Pattern("some_pic.png").targetOffset(0,18)) # ref for list 1
clickList(top1)

type(' ', KeyModifier.CTRL)

top2 = find(Pattern("some_other_pic.png").targetOffset(0,18)))# ref for list 2, may be different targetOffset
clickList(top2)

but i guess it didn't work :-\

Revision history for this message
hakim johari (hakim-johari) said :
#4

is it necessary to have 2 different kind of pattern? or I can use the same pattern for top1 and top2?

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

I guess I did not understand right.

Do you want to select more than one entry in the same list?

Revision history for this message
hakim johari (hakim-johari) said :
#6

yeah

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

ok, then forget about comment #1 (I understood, you have 5 different lists side by side)

select more than one entry in the same list:

keyDown(Key.CTRL) # press and hold

... all the other actions that need the ctrl-key held down

keyUp()

Take care: the section between keyDown and keyUp MUST run without any error, means the keyUp() has to be run definitely.
Otherwise you have to stop and restart the IDE, to release the ctrl-key.

If errors might happen:

try:
    keyDown(Key.CTRL)
    ... your other stuff
    keyUp()
catch:
    keyUp()

this would take care, that keyUp() is processed in all cases

Can you help with this problem?

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

To post a message you must log in.