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
compare from group of bmps
Moderators: Dorian (MJT support), JRL
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
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
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 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
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
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]
[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]
-
- Newbie
- Posts: 17
- Joined: Sun Dec 21, 2008 6:58 am
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]
[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]