Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
87 views
in Technique[技术] by (71.8m points)

python - Image found even if not on screen

I'm trying to build a basic macro to tell if my lifebar is low but I have a bug in my program where even when lifebar.png isn't on the screen it will still print "I can see it." Can anyone explain why this is happening? Also can someone show me an example where pyautogui locates an image with x confidence and then clicks it? Thanks.

lasthit = pyautogui.locateAllOnScreen('lifebar.png', confidence=(1))
def new_method(lasthit):
    while True:
        if lasthit is not None:
            print("I can see it.")
            time.sleep(2)
        else:
            print("image not found")
            time.sleep(0.5)
new_method(lasthit)
question from:https://stackoverflow.com/questions/65622888/image-found-even-if-not-on-screen

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...