sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #14492
Re: [Question #213704]: click( img ) not working..
Question #213704 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/213704
Status: Open => Answered
RaiMan proposed the following answer:
--- first an example solution for your searching around an d click on
nearest
(download a zipped .sikuli, so you might test it:
https://dl.dropbox.com/u/42895525/circles.sikuli.zip )
# this should run on https://launchpad.net/sikuli
import math
# calculate the distance between 2 points
def calcDist(p1, p2):
return int(math.sqrt(pow(p1.x-p2.x, 2) + pow(p1.y-p2.y, 2)))
# some images to search
imga = "1352554482821.png"
imgb = "1352554500021.png"
imgc = "1352554522969.png"
imgd = "1352554540352.png"
# put images in list
images = [imga, imgb, imgc, imgd]
# got to a reference point
ref = "1352554569162.png"
mRef = find(ref)
hover(mRef)
mRefCenter = mRef.getCenter()
# look for the images, highlight the found ones
matches = []
for img in images:
matches.append(exists(img, 0))
if matches[-1]:
matches[-1].highlight()
# sort the matches by distance to ref point
matches.sort(key = lambda m : calcDist(m.getCenter(), mRefCenter))
# hover on every image, neareast first, switch off highlight
for m in matches:
if m:
hover(m)
m.highlight()
wait(3) # give some time to watch ;-)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.