visual calculator button need help

Asked by Ninja Mustang

hello,

I'm trying to simulate a calculator by adding a bunch of numbers from a file.

I have a myfile.txt containing some values, example:
price quantity
1.99 2
3.49 20
0.99 15

I'd like to open the calculator from Windows. So the keypads are there.

I'd capture the screen of each button.
img0 = button_number_0
img1 = button_number_1
...
img9 = button_number_1
etc...

I defined a multidimensional array
keys = [[img0][0],...,[img9[[9]]

now say I read the myfile.txt and multiply the price * quanity in each row, and I also want to see the mouse is clicking on corresponding key of the calculator.

How would I go about doing that?

I checked http://groups.csail.mit.edu/uid/projects/sikuli/sikuli-uist2009.pdf under Visual Dictionary but when I did this, it gave me 'dict' is not callable.

VisualDict = {}
my_keys = VisualDict({img0:"0",img1:"1",.....img9:"9"})
click(my_keys[img0])

gave error
TypeError: 'dict' object is not callable

Thank you!

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
Ninja Mustang (ninjamustang) said :
#1

I think a better question would be, how do I reference a value to an image? such as 9 would go and click(img9)

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

I do not understand, why this complexity is needed.

keys = (img0, img1, ..., img9) # a list of the images

... now if you want to click the number 0

click(keys[0])

in any case, I would restrict the search area dynamically to the number pad

pad = <evaluated region of number pad>
pad.click(keys[0])

Revision history for this message
Ninja Mustang (ninjamustang) said :
#3

actually i got it, it's probably not good but it worked.

I used if the read value is 0, then click img0.

if (val == 0):
    click(img0)

Revision history for this message
Ninja Mustang (ninjamustang) said :
#4

Thanks RaiMan, that solved my question.

Revision history for this message
Ninja Mustang (ninjamustang) said :
#5

I like your solution! Thanks!!!!