compare from group of bmps

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
crossedout
Newbie
Posts: 17
Joined: Sun Dec 21, 2008 6:58 am

compare from group of bmps

Post by crossedout » Thu Feb 12, 2009 2:26 am

Hello again.

I'm sure there is an easy way of doing what I'm trying to do, but the only way I can think about it is long and difficult.

I have a section of a screen that is an image representation of a score or balance. I can't get a text capture on it because it is images. The code I'm hoping to not have to use would look like this (small snippet):

ScreenCapture>163,553,170,569,FirstDigit.bmp
CompareBitmaps>FirstDigit.bmp,0.bmp,nPercent
If>nPercent=100
let v_FirstDigit=0
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,1.bmp,nPercent
If>nPercent=100
let v_FirstDigit=1
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,2.bmp,nPercent
If>nPercent=100
let v_FirstDigit=2
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,3.bmp,nPercent
If>nPercent=100
let v_FirstDigit=3
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,4.bmp,nPercent
If>nPercent=100
let v_FirstDigit=4
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,5.bmp,nPercent
If>nPercent=100
let v_FirstDigit=5
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,6.bmp,nPercent
If>nPercent=100
let v_FirstDigit=6
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,7.bmp,nPercent
If>nPercent=100
let v_FirstDigit=7
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,8.bmp,nPercent
If>nPercent=100
let v_FirstDigit=8
ELSE
ENDIF
CompareBitmaps>FirstDigit.bmp,9.bmp,nPercent
If>nPercent=100
let v_FirstDigit=9
ELSE
ENDIF


repeated for the second and third digits.

Also, what is the suggested way of connecting those digits together to form the actual number again in text form.

Thanks for your help
Brad

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Feb 12, 2009 4:03 am

Your method for finding the number (if it is only 3 digits) seems like it will work and is not actually so complicated. I'd suggest you try it and see how accurate it proves to be.

As for combining the numbers simply use Concat>

at the beginning of your code use Let>TheNumber=

then as you find the actual number in each place Concat>TheNumber,v_FirstDigit
Concat>TheNumber,v_SecondDigit
Concat>TheNumber,v_ThirdDigit

crossedout
Newbie
Posts: 17
Joined: Sun Dec 21, 2008 6:58 am

Post by crossedout » Thu Feb 12, 2009 5:12 am

I wish I could be an automation wizard. Thanks for the reply.

Yes, if the number were only two or three digits, that would probably work fine, but the number is about 7 digits.

I'm sure it is fine still, it just seems like there would be a shorter way of doing it. Is it still the suggested way?

Thanks again.
Brad

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Feb 12, 2009 6:01 am

Looks like a perfect application for a subroutine to me. This is not a tested script, merely a suggested method.

[code]
Let>Number=
Let>Counter=0

//Usage:
//GoSub>CheckDigit,TopLx,TopLY,BottomRX,BottomRY

GoSub>CheckDigit,163,553,170,569
GoSub>CheckDigit,173,553,180,569
GoSub>CheckDigit,183,553,190,569
//etc. for however many digits you want
MDL>Number

SRT>CheckDigit
let>v_FirstDigit=NotFound
Add>Counter,1
ScreenCapture>CheckDigit_var_1,CheckDigit_var_2,CheckDigit_var_3,CheckDigit_var_4,Digit.bmp
CompareBitmaps>Digit.bmp,0.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=0
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,1.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=1
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,2.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=2
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,3.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=3
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,4.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=4
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,5.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=5
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,6.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=6
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,7.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=7
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,8.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=8
Goto>Found
ENDIF
CompareBitmaps>Digit.bmp,9.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=9
Goto>Found
ENDIF

Label>Found
// As Paul suggested:
If>%v_FirstDigit%NotFound
Concat>Number,%v_FirstDigit%
EndIf
MDL>Digit %Counter% not found
Else
END>CheckDigit
[/code]

crossedout
Newbie
Posts: 17
Joined: Sun Dec 21, 2008 6:58 am

Post by crossedout » Thu Feb 12, 2009 7:42 am

Wow. You guys really are Automation Wizards.

Thank you for the suggestion. I have no clue about subs.

I will look into learning what that is doing.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Feb 12, 2009 2:30 pm

Don't know what I wasn't thinking.... Since your digit image files names are numbered we could also shorten up the primary code in the subroutine by using a Repeat/Until. Here's the same thing as above but slightly condensed. Again this is not tested.

[code]
Let>Number=
Let>Counter=0

//Usage:
//GoSub>CheckDigit,TopLx,TopLY,BottomRX,BottomRY

GoSub>CheckDigit,163,553,170,569
GoSub>CheckDigit,173,553,180,569
GoSub>CheckDigit,183,553,190,569
//etc. for however many digits you want
MDL>Number

SRT>CheckDigit
let>v_FirstDigit=NotFound
Let>kk=-1
Add>Counter,1
ScreenCapture>CheckDigit_var_1,CheckDigit_var_2,CheckDigit_var_3,CheckDigit_var_4,Digit.bmp

Repeat>kk
Add>kk,1
CompareBitmaps>Digit.bmp,%kk%.bmp,nPercent
If>nPercent=100
let>v_FirstDigit=%kk%
Let>kk=9
ENDIF
Until>kk,9

// As Paul suggested:
If>%v_FirstDigit%NotFound
Concat>Number,%v_FirstDigit%
EndIf
MDL>Digit %Counter% not found
Else
END>CheckDigit
[/code]

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts