We have written a script (TreeNodeOpen.script) to look for an image, then create a fairly small SearchRectangle to the left of it to do more in.
Params ImageTime, ImageName, Action MoveTo (1,1) if imagefound (ImageTime, ImageName) then (* Variablelizes image location information from the found image and uses them to create search boundaries to be used later in the script. *) set TestLeft = left(ImageRectangle(ImageName)) set TestTop = top(ImageRectangle(ImageName)) set TestBottom = bottom(ImageRectangle(ImageName)) set SearchAreaStart = TestLeft - 32 set UpperLeft = (SearchAreaStart,TestTop) set BottomRight = (TestLeft,TestBottom) (* Search for the tree node right arrow. *) set the SearchRectangle to (UpperLeft, BottomRight) if imagefound ("TreeNodeUnopened") then log "Expected image was found, so opening: " & ImageName do Action && foundImageLocation() MoveTo (1,1) else if imagefound ("TreeNodeOpened") then log "Tree node was found to be open already: " & ImageName Return else log"Expected Image Not Found: " & "TreeNodeOpened" WaitFor "1.0", "TreeNodeOpened" Return end if end if else log "Expected Image Not Found: " & ImageName WaitFor "1.0", ImageName return end if
The script works great if we call it from another script once. For example:
TreeNodeOpen 8, "test_image", click
But, if we call it twice, the second run through fails because the SearchRectangle has not been reset. For example:
TreeNodeOpen 8, "test_image", click TreeNodeOpen 8, "test_image2", click
I have tried incorporating “Set the SearchRectangle to ()” at various locations in the TreeNodeOpen.script with no luck.
The only way I have been able to get this script to work when called more than once from another script is to do the following:
TreeNodeOpen 8, "test_image", click Set the SearchRectangle to () TreeNodeOpen 8, "test_image2", click
I don’t like my solution. What am I missing about getting this line to reset the SearchRectangle to work within the TreeNodeOpen.script?