New question #689782 on Sikuli:
https://answers.launchpad.net/sikuli/+question/689782

I have a auction app which reads the region on the screen containing 
information on the current bid position and the amount the vendor wants in 
order to sell the item immediately. The fields are shown on the screen as shown 
in the following example.

(CR)  4,000     (CR) 20000

Because the size of the area containing the amounts of the bid and the ask can 
vary what I do is define a region which contains all of the information and 
then read the text which I then manipulate to extract the numbers as integers. 
I do this by looking for a special character in the text (The ")" character 
ascii 169) and then using that to split out the number which I  then convert 
into an integer. I have included a simple test piece of code below.

The problem is that after a variable amount of times read the text I will get a 
-1 returned indicating that the special character was not found even though it 
was on the screen. If I rerun the code on the same image it will work with 
nothing changed in either the code or on the screen.

My question therefore is whether  the region.text() call is problematic or if 
there is an issue with the way I am doing things. As usual any help would be 
much appreciated.

The code snippet:


import re
loc_code = 0
if loc_code == 0:
    ascii_reg =(Region(460,381,366,41))
else:    
    ascii_reg = (Region(561,762,258,30))
ascii_text = ascii_reg.text()
ore_count =0 
ore = len(ascii_text)

while ore_count < ore:
    print("Character is ...",ascii_text[ore_count])
    print("Character is ...",ord(ascii_text[ore_count]))
    ore_count +=1

result = ascii_text.find(chr(169))
print("The result is -->",result)
result2 =ascii_text.find(chr(169),result+1)
print("The second result is -->",result2,result+1)
bid_val = ascii_text[result:result2]
# print("The ask is -->",ask_val)
bid_val_i =  re.sub("[^0-9]","",bid_val)   
bid_s = bid_val_i.replace(',','')    
int_bid_val = int(bid_s)

ask_val = ascii_text[result2+1:ore]
ask_val_i = re.sub("[^0-9]","",ask_val)
ask_s = ask_val_i.replace(',','')    
int_ask_val = int(ask_s)

print("The bid is ",bid_s)
print("The ask is ",ask_s)





-- 
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     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to