Exist method is not work when trying to call it in a while function

Asked by Yifan Ding

Hello, everyone, I am trying to use exists method to determine whether the picture has disappeared from the screen.
For Example, when I trying to change somebody's charactor in a zoom meeting. I want to know when his name disappeared from the userlist area. So I called this exists method in a while loop. The code shows below:

def Sikuli_Exist(folder_name, png_name,is_Exist):
    try:
        scr = Screen()
        strOS = GetCurrentOS()
        print_log("The os system is:%s"%strOS)
        if strOS.find("Windows") != -1:
            img_path = gStaticSettings.WIN_SNAPSHOT_PATH + os.sep + folder_name + os.sep + png_name
            print_log("The img_path is:%s" % img_path)
            if os.path.exists(img_path):
                print_log("The image %s is existed in files" % png_name)
                time_count = 0
                while (time_count <= 10):
                    result = scr.exists(img_path)
                    print_log("image position result is %s" % result)
                    if result != None:
                        print_log("This image is exist")
                        if (is_Exist):
                            return 1
                        else:
                            time.sleep(1)
                            time_count += 1
                    else:
                        print_log("This image is disapear")
                        if (is_Exist):
                            time.sleep(1)
                            time_count += 1
                        else:
                            return 1
                return -1
            else:
                print_log("The image %s is not existed in files, maybe because of capture failed" %png_name)
                return -1

is_Exist == True means I am trying to prove this image is in our screen.
is_Exist == False means I am trying to prove this image has disappeared from our screen.

It works on my computer but on other computer, it will print obj position constantly, even this username's image has disappeared from the user list area.
It happened sometimes on that computer, I guess maybe because of cache or some similarity limit?
By the way, I am using https://github.com/RaiMan/sikulix4python and I also tryed exists(img_path, 10.0) by its internal timer.
And I also tried has(), wait(), waitVanish() method. They are just not very stable.

Question information

Language:
English Edit question
Status:
Expired
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.