//code for command to create a search rectangle based on the position of an image
on SetSearchRectangleCommand image, x_distance, y_distance, x_offset, y_offset
put ImageRectangle(Image:image, WaitFor:5) into ImageRectangle
set StartLeftSearch = left(ImageRectangle) + x_offset
set StartTopSearch = top(ImageRectangle) + y_offset
set EndRightSearch = StartLeftSearch + x_distance
set EndBottomSearch = StartTopSearch + y_distance
set UL_Search=(StartLeftSearch,StartTopSearch)
set BR_Search=(EndRightSearch,EndBottomSearch)
set the searchRectangle to (UL_Search,BR_Search)
log UL_Search
log BR_Search
end SetSearchRectangleCommand
//code for command to create a search rectangle based on the position of text
on SetSearchRectangleCommandBasedOnText text, x_distance, y_distance, x_offset, y_offset
put ImageRectangle(Text:text, WaitFor:5) into ImageRectangle
set StartLeftSearch = left(ImageRectangle) + x_offset
set StartTopSearch = top(ImageRectangle) + y_offset
set EndRightSearch = StartLeftSearch + x_distance
set EndBottomSearch = StartTopSearch + y_distance
set UL_Search=(StartLeftSearch,StartTopSearch)
set BR_Search=(EndRightSearch,EndBottomSearch)
set the searchRectangle to (UL_Search,BR_Search)
log UL_Search
log BR_Search
end SetSearchRectangleCommandBasedOnText
//function to read text at a location defined by the same line as the line text occurring beneath the image
function ReadTextOnSameLine LineText, image1, rowheight
if rowheight = “” then
set rowheight = 2
end if
put ImageRectangle(Text:LineText,WaitFor:5) into ImageRectangle1
put ImageRectangle(Image:image1,WaitFor:5) into ImageRectangle2
set StartLeftSearch = left(ImageRectangle2)
set StartTopSearch = top(ImageRectangle1) - 2
set EndRightSearch = right(ImageRectangle2)
set EndBottomSearch = bottom(ImageRectangle1) + rowheight
set UL_Search=(StartLeftSearch,StartTopSearch)
set BR_Search=(EndRightSearch,EndBottomSearch)
set thevalue to ReadText(UL_Search,BR_Search)
log thevalue
return thevalue
end ReadTextOnSameLine
//function to read text at a location defined by an image
function ReadTextFromBelowImageLocation image1, rowheight, columnwidth
if rowheight = “” then
set rowheight = 2
end if
put ImageRectangle(Image:image1,WaitFor:5) into ImageRectangle1
set StartLeftSearch = left(ImageRectangle1)
set StartTopSearch = bottom(ImageRectangle1) +2
set EndRightSearch = right(ImageRectangle1) + columnwidth
set EndBottomSearch = bottom(ImageRectangle1) + rowheight
set UL_Search=(StartLeftSearch,StartTopSearch)
set BR_Search=(EndRightSearch,EndBottomSearch)
set thevalue to trimAll(ReadText(UL_Search,BR_Search),contrast:on)
log thevalue
return thevalue
end ReadTextFromBelowImageLocation
//trimAll(ReadText((“UpperLeft”,“LowerRight”), ValidPattern: “[A-Za-z]+.py”))
//readtext(“UpperLeft”,“LowerRight”,contrast:on, contrastColor:(0,0,128),contrastTolerance:25)
//function to read text at a location defined by the same line as the first image occurring beneath the second image
function ReadTextOnSameLineAsImage image1, image2
put ImageRectangle(Image:image1,WaitFor:5) into ImageRectangle1
put ImageRectangle(Image:image2,WaitFor:5) into ImageRectangle2
set StartLeftSearch = left(ImageRectangle2)
set StartTopSearch = top(ImageRectangle1) - 2
set EndRightSearch = right(ImageRectangle2)
set EndBottomSearch = bottom(ImageRectangle1) + 2
set UL_Search=(StartLeftSearch,StartTopSearch)
set BR_Search=(EndRightSearch,EndBottomSearch)
set thevalue to ReadText(UL_Search,BR_Search)
log thevalue
return thevalue
end ReadTextOnSameLineAsImage
//function to find an image at a location defined by the same line as where text is located and extending a given distance
function FindImageOnSameLineAsText text_string, distance, search_image
put ImageRectangle(Text:text_string,WaitFor:5) into ImageRectangle1
set StartLeftSearch = left(ImageRectangle1)
set StartTopSearch = top(ImageRectangle1) - 2
set EndRightSearch = right(ImageRectangle1) + distance
set EndBottomSearch = bottom(ImageRectangle1) + 2
set thevalue = ImageLocation(search_image)
log thevalue
return thevalue
end FindImageOnSameLineAsText
on FindAndClickImage image_name,WFV,MsgType,SR
if WFV = “” then
set WFV=0
end if
If SR="" then
put () into SR
// set the searchRectangle to ()
Else
// set the searchRectangle to SR
End If
if ImageFound(WFV, image:image_name, searchRectangle:(SR)) then
Wait 1
click FoundImageLocation()
else if MsgType = "none" then
else if MsgType = "warning" then
CaptureScreen (Name: "warning_"&image_name)
LogWarning "The image"&&image_name&&"could not be found."
else if MsgType = "error" then
CaptureScreen (Name: "error_"&image_name)
LogError "The image"&&image_name&&"could not be found."
end if
end FindAndClickImage
on FindAndClickText text_string,WFV,MsgType,SR
if WFV = “” then
set WFV=0
end if
If SR="" then
set the searchRectangle to ()
Else
set the searchRectangle to SR
End If
If ImageFound(WFV, (text:text_string)) then
Wait 1
Click FoundImageLocation()
else
CaptureScreen (Name: "warning_"&text_string, Rectangle: SR)
LogWarning "The text"&&text_string&&"could not be found."
End If
set the searchRectangle to ()
end FindAndClickText
function CheckForBlankVariable variable_name, default_value
if variable_name="" then
set thedata = default_value
else
set thedata = variable_name
end if
return thedata
end CheckForBlankVariable