How to get dynamic text


I have a window that displays a winning card number which will be different from one session to another. I would like to retrive the text from the window without relying on the imag. How do I accomplish this?


Attached is a suite that will allow you to do just that. Extract the suite from the attached zip file. Inside, there are two scripts. MainExample and IdentifyCharacterImages. MainExample is just an example of how IdentifyCharacterImages can be used.

The workflow is like this:

  1. Capture images of the characters you care about.
  2. Capture boundaries for restricting the search rectangle. This is important, so that you only get the list of characters that you want…not everything on the screen.
  3. Add IdentifyCharacterImages and call it in your script

An example:

put ImageLocation("StakeTL") into coordA
put ImageLocation("StakeBR") into coordB
CaptureScreen (name: "Stake" , Rectangle: (coordA,coordB))
put identifyCharacterimages("credits", (coordA,coordB)) into numbers
put first item of numbers into currency
put second item of numbers into Stake
log "you are going to play for" && Stake && currency

The magic is done in the identifyCharacterimages script which is included in the suite. It basically lines them all up and gets you the text back.


Thank you for the response.

I am not sure what i need to do. Do I need to capture the image that holds the dynamic card number?

Thank you.

You need to capture images of the individual characters that make up the text you need to identify. This approach works well with numbers because it is small set of images to search for. It can work with words and phrases, but it is rather slow and gets slower the larger the block of text you are parsing.