I am trying to read text from a set of imageloction coordinates. I am able to find the coordinates fine but when trying to perform the readtext of a different location will get various errors from various attempts. but the main error is expected numbers, dates and /or list; got [ the locations it found]
Here is what I have so far and will error in the 3rd line. I have tried different numbers in the searchrectangle and still get the errors.
put ImageLocation(text:"Available Coverages", searchrectangle: (240,856,498,975)) into covloc
log covloc
*put (covloc+(85,0,85,20)) into covloc*
put readtext (covloc) into covinfo
log covinfo
try logging covloc after modifying them. I mean after put(covloc+(85,0,85,20)) into covloc to verify if the new co-ordinates are as expected. Am not sure if it works.
I think your issue is that imagelocation() results in a single set of coordinates. You can either change it to imagerectangle() or add the top left difference and the bottom right difference to the variable.
put ImageRectangle(text:"Available Coverages", searchrectangle: (240,856,498,975)) into covloc
put (covloc+(85,0,85,20)) into covloc
put readtext (covloc) into covinfo
OR
put ImageLocation(text:"Available Coverages", searchrectangle: (240,856,498,975)) into covloc
put (covloc+(85,0), covloc +(85,20)) into covloc
put readtext (covloc) into covinfo
This may contain more moving parts than you require, but here is a function that I use frequently.
Hope this helps.
Dave
//function to read text at a location defined by the same line as the anchor text extending for a given distance
function ReadTextOnSameLineAsTextForGivenDistance myText, distance, mySearchRectangle, mycontrast, mycontrasttolerance, myvalidcharacters, myvalidpattern
put ImageRectangle(Text:myText,WaitFor:5,SearchRectangle:mySearchRectangle) into ImageRectangle1
set StartLeftSearch = right(ImageRectangle1) + 2
set StartTopSearch = top(ImageRectangle1)
set EndRightSearch = right(ImageRectangle1) + distance
set EndBottomSearch = bottom(ImageRectangle1) + 2
set UL_Search=(StartLeftSearch,StartTopSearch)
set BR_Search=(EndRightSearch,EndBottomSearch)
set thevalue to ReadText((UL_Search,BR_Search),contrast: mycontrast, contrastTolerance:mycontrasttolerance, ValidCharacters:myvalidcharacters, ValidPattern:myvalidpattern)
log UL_Search
log ColorAtLocation(BR_Search)
log thevalue
return thevalue -- Must be last line of function
end ReadTextOnSameLineAsTextForGivenDistance
Hi, let me mention, that ReadText works with [x,y] coordinate as well. So for reading single word at a certain position the ReadText(x,y) may be the prefered approach. Often with more stable results.
BR