1
import shutil
import os
wait(5)
dir = os.path.dirname(getBundlePath()) # the folder, where your script is stored
img = capture(SCREEN) # snapshots the screen
shutil.move(img, os.path.join(dir, "shot.png")) # to make it persistent
wait(10)
dir = os.path.dirname(getBundlePath()) # the folder, where your script is stored
img2 = capture(SCREEN) # snapshots the screen
shutil.move(img2, os.path.join(dir, "shot2.png")) # to make it persistent
if img == img2:
popup("hello")
else:
popup("hi")
它总是给弹出嗨不是你好......虽然我没有改变屏幕。如何比较使用sikuli的两个图像的内容?
我可以理解,这两个是两个不同的图像名称,这就是为什么总是else块正在工作。但有可能比较这两个图像。两幅图像之间存在一些差异的内容。 无法上传代码,所以已评论它..帮助,如果有人知道。
你似乎是比较包含文件名的字符串,而不是图像内容本身。尝试添加一些像'print(img)'和'print(img2)'这样的语句来理解正在发生的事情,并阅读有关如何实际比较图像的文档。 – gerrit 2012-07-19 08:08:47
是的尝试过,它也给出了IMG的信息,但我想要在内容上有所不同 – user1537127 2012-07-19 09:42:03