Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-17 Thread RaiMan
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

Status: Open => Answered

RaiMan proposed the following answer:
ok, the principal approach is ok.

the return value of input() is a string. Python has a feature, to convert a 
string into a number:
num = int(str)

If the entered string represents a valid number, the x will contain this
number, if not, the script will crash with an exception (which in turn
can be handled).

For your case this would be the solution base:

xs = "" # the number as String
while xs == "":
try:
xs =input("Input 1st Number:")
xn = int(xs) # check wether xs contains a valid number
except:
xs = "" # reset xs in case of not valid and repeat

now you need a sequence, to enter the number having n digits:

for digit in xs: # step through the digits in the string left to right
if digit == "1":
click("digit1.png")
   elif digit == "2":
click("digit2.png")
...
else:
click("digit0.png")

... using if ... elif ... else is more efficient in this case, where
only one case is valid among the possible 10 cases, since max 9 cases
will be evaluated and the evaluation will end with the first success.

Since you need this sequence for 2 numbers, you could put it in a
function:

def enterNumber(number):
for digit in number: # step through the digits in the given string left to 
right
if digit == "1":
click("digit1.png")
elif digit == "2":
click("digit2.png")
...
else:
click("digit0.png")

... and the number input we add to a def also:

def enterNumber(text):
number = "" # the number as String
while number == "":
try:
number =input(text)
int(number) # check wether number contains a valid number
except:
number = "" # reset number in case of not valid and repeat

for digit in number: # step through the digits in number left to right
if digit == "1":
click("digit1.png")
elif digit == "2":
click("digit2.png")
...
else:
click("digit0.png")


now your script will look like this:

def enterNumber(text):
number = "" # the number as String
while number == "":
try:
number =input(text)
int(number) # check wether number contains a valid number
except:
number = "" # reset number in case of not valid and repeat

for digit in number: # step through the digits in number left to right
if digit == "1":
click("digit1.png")
elif digit == "2":
click("digit2.png")
...
else:
click("digit0.png")

enterNumber("Input 1st Number:")

ops = "+-*/"
while not op in ops:
op= input("choose operation to be used: + - * /")

# operation to be used + - * / 
if op == "+":
click("plus.png")
elif op == "-":
click("minus.png")
elif op == "*":
click("mul.png")
else:
click("div.png")

enterNumber("Input 2nd Number:")

click("equal.png")

If you decide to do more complex stuff with SikuliX, you should learn some 
Python basics:
http://sikulix-2014.readthedocs.org/en/latest/index.html

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-17 Thread RaiMan
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

RaiMan proposed the following answer:
ok, I just realized that masuo already mentioned the int() function and I have 
to admit, that I was not aware of isdecimal().
But since this only works on unicode strings, I still would use int() in this 
case.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-16 Thread masuo
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

masuo proposed the following answer:
If you want to convert a string to an integer , use the function (for example, 
isdecimal()). 

errmsg = ""
while True:
msg = "Input a number\n" + errmsg
ans = input(msg)
if ans == None:
cancel = True   
break
if ans.isdecimal():
x = int(ans)
cancel = False
break
else:
errmsg = "'" + ans +"'" + " is not a number"

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-16 Thread masuo
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

masuo proposed the following answer:
sorry:
If you want to evaluate the input value, use the function (for example, 
isdecimal()).
If you want to convert a string to an integer, use the function (for example, 
int()).

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-16 Thread Jenelle
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

Status: Answered => Open

Jenelle is still having a problem:

x= input("Input 1st Number:")
y= input("Input 2nd Number:")
op= input("choose operation to be used: + - * /")

if x == "1":
click("1442372005556.png")
if x == "2":
click("1442372023449.png")
if x == "3":
click("1442372434642.png")
if x == "4":
click("1442372451565.png")
if x == "5":
click("1442372460538.png")
if x == "6":
click("1442372475324.png")
if x == "7":
click("1442372486937.png")
if x == "8":
click("1442372506844.png")
if x == "9":
click("1442372515627.png")
if x == "0":
click("1442372522700.png")

/*opeationr to be used + - * / */
if op == "+":
click("1442457788556.png")
if op == "-":
click("1442457811305.png")
if op == "*":
click("1442457824868.png")
if op == "/":
click("1442457838430.png")
  
if y == "1":
click("1442372005556.png")
if y == "2":
click("1442372023449.png")
if y == "3":
click("1442372434642.png")
if y == "4":
click("1442372451565.png")
if y == "5":
click("1442372460538.png")
if y == "6":
click("1442372475324.png")
if y == "7":
click("1442372486937.png")
if y == "8":
click("1442372506844.png")
if y == "9":
click("1442372515627.png")
if y == "0":
click("1442372522700.png")


click("1442457857653.png") /*equal sign image


so this is my codes looks like. And my problem here now is... I
can't manipulate a number that composed of more than 1 digit :( Im so
sorry, this is my first time using sikuli. I can't even find answers in
google. :'(  Im so desperate right now. tho I  really want to learn this
thing. thank you

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-15 Thread Eugene S
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

Status: Open => Answered

Eugene S proposed the following answer:
what's wrong with the solution I offered?

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-15 Thread Eugene S
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

Status: Open => Answered

Eugene S proposed the following answer:
this has nothing to do with Sikuli but...

input doesn't have the ability to check the input type. You will have to
process it yourself. Below is a trivial example:

while True:
if type(input("Input a number")) is int:
print "That's an integer"
break
else:
print "That's not an integer. Enter integer!"

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #271443]: How can I input a number and accept it as an integer in sikuli?

2015-09-15 Thread Jenelle
Question #271443 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/271443

Jenelle posted a new comment:
I need a number inputted by the user to automate in my calculator
Do you have any idea how to do it?
I want to make an automation where sikuli will ask the user to give  two(2) 
integers/number and sikuli will do the rest to make it automated in inputing in 
calculator.
please help :'(

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp