I have a chunk of code that I re-use over and over again in my scripts and I would like to create a function out of it that takes 3 parameters.
The code below first sets the search rectangle to a certain part of the application (this will be the 1st parameter). It then looks for an image (the 2nd parameter) by scrolling in a certain direction (the 3rd parameter). So I’d like a function called imageSearcher that would be called in the following way to execute the code below imageSearcher sharedObjectsArea selectionMales Down.
The third parameter will be the direction in which the scroll occurs first so I’ll be changing the code to change direction if it has not found the object whilst searching in the initial direction.
Basically I’m new to the whole Handlers, Helpers thing in EggPlant and I was wondering what people’s thoughts were on how to go about this? :?
Set the SearchRectangle to ("sharedObjects", "bottomRightWorkspace") -- 1st parameter
put ImageLocation("scrollBarVertical") into coord
SetOption RemoteWorkInterval, 0.2
Set the ImageSearchTime to 0.25
SetOption ImageSearchCount, 2
repeat until imageFound("selectionMales") -- 2nd parameter
Drag coord
add (0, 5) to coord
Drop coord -- drag 5 pixels in the down direction -- 3rd parameter
end repeat
SetOption RemoteWorkInterval, 0.7 -- back to default value
Set the ImageSearchTime to 1.8 -- back to default value
SetOption ImageSearchCount, 7 -- back to default value
Set the SearchRectangle to () -- back to default value