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