Not able to click button on some different computers using pyautogui library in python

14 views Asked by At

here is piece of code in am displaying

in which i have used pyautogui.locateOnScreen('ProgramFinished.png',grayscale=True,confidence=0.8)

to locate the button and then click it/ i have given a screenshot of the button in the current folder

def program():
    open("mtb-Programmer")
    time.sleep(4)
    a=1
    try:
        current_directory = os.getcwd()
        print(current_directory)
        device_under_test=fileopen.read_config('i')
        Open=pyautogui.locateOnScreen('Open.png',grayscale=True, confidence=0.8)
        pyautogui.click(Open)
        time.sleep(2)
        hexfile=fileopen.read_FW_names('Hex',device_under_test)
        file_path = os.path.join(current_directory,hexfile)
        pyautogui.write(file_path)
        time.sleep(5)
        pyautogui.press('enter')
        time.sleep(2)
        Connect=pyautogui.locateOnScreen('Connect.png',grayscale=True, confidence=0.8)
        pyautogui.click(Connect)
        pyautogui.moveTo(1000,1000)
        time.sleep(2)
        FlashDetected=pyautogui.locateOnScreen('Disconnect.png',grayscale=True,confidence=0.8) or pyautogui.locateOnScreen('FlashDetected.png',grayscale=True,confidence=0.8)
        print("Flash banks detected")
        Erase=pyautogui.locateOnScreen('Erase.png',grayscale=True,confidence=0.8)
        pyautogui.click(Erase)
        time.sleep(1)
        Program=pyautogui.locateOnScreen('program.png',grayscale=True,confidence=0.8)
        pyautogui.click(Program)
        pyautogui.moveTo(500,500)
        time.sleep(7)
        try:
            Finished=pyautogui.locateOnScreen('ProgramFinished.png',grayscale=True,confidence=0.8)
            print("programming done")
        except:
            print("Hex file correupted/Not Flashed properly") 
        Disconnect=pyautogui.locateOnScreen('Disconnect.png',grayscale=True,confidence=0.8)
        pyautogui.click(Disconnect)   

    except:
        print("kit probe not connected / The DUT is not powered On")
        a=0

    time.sleep(1)
    print("Closing the programmer....")
    close("mtb-Programmer")
    time.sleep(4)
    print("Closed")
    return a

I am expecting to click some set of buttons in pattern to program a board
enter image description here the Interface

enter image description here to click

the Script is working on some computers/laptop but not working sometimes on specific PC/laptops

0

There are 0 answers