Click random item at the given range

Asked by hakim johari

Hi,

I've got a couple question regarding about scripting of sikuli.

1. How can I click/select a random item (because the name of the item will be different from time to time) in a specific region?

2. How can I select "tomorrow" date?

Thanks,
Hakim.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

at 1.
not really clear what you mean by random item.
If it is an image whose contents might change from time to time, then you cannot use it to search for.
You have to use some fixed image in the neighborhood and click using any of the offset features.

at 2.
I guess we are talking about Python scripting:
http://docs.python.org/2.6/library/datetime.html

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

1. I got a bunch of files. I need to pick 1 random file to delete it. The files name will be random when someone's upload it into the system.

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

you might send me a screenshot silently to my mail (https://launchpad.net/~raimund-hocke) with some comments on what you want to achieve.

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

2. I got the general idea.

import time

time.strftime('%d-%m-%Y')

to call the time now. (right? this is what I've been using)

but I still don't know how to ask sikuli to select/type tomorrow's date?

click(pattern("some-reference-pic.png")targetOffset(x,y)))
type(*tomorrow's date* + Key.TAB) #this is where I want sikuli to type tomorrow's date
type(*tomorrow's date*) #same with this

many thanks.

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

ok i already got this

my script

import datetime

tomorrow = datetime.date.today() + datetime.timedelta(1)

click(Pattern("from.png").similar(0.75).targetOffset(54,0))
type(str(tomorrow))
click(Pattern("to.png").targetOffset(39,1))
type(str(tomorrow))

but this is type as format Y-m-d

I need a format d-m-Y

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

use strftime() instaed of str()

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

Thanks RaiMan, that solved my question.