Oct-13-2024, 01:09 PM
Hello Everyone! This is my first post here, so be gentle. I'm trying to teach myself Python and have almost finished my first "project", but I've run into a snag. Essentially, I'm trying to get Python to perform 1 action if a particular image is found, and another action if the same image isn't found. os.path tells me the .png file exists, but the image simply isn't being found...I'm not even getting any errors. I've compared the .png file to the actual image and see no noticeable differences. Here is the code I'm using, and I don't see a difference in it versus the snippets I've found online whilst researching this.
import xlwings as xlw import pyautogui as pyauto import pyperclip as pyclip import time #import os def Get_Member_Info (x_loc, y_loc): wbmd = xlw.Book('Member_Details.xlsx') md_info = wbmd.sheets["Member_Info"] mdnlr = md_info.cells(md_info.cells.last_cell.row, 3).end('up').row mdilr = md_info.cells(md_info.cells.last_cell.row, 4).end('up').row #rename_loc = pyauto.locateOnScreen('Rename.png', confidence=.5) rename_loc = pyauto.locateOnScreen('Rename.png') #Clear the clipboard. pyclip.copy("") pyauto.PAUSE = .50 #Click on targeted member. #pyauto.click(x=x_loc, y=y_loc) # pyauto.click(x=2150, y=344) #Click on View Player. #pyauto.click(x=2202, y=553) #Click on Member Name to Copy. #time.sleep(.5) pyauto.moveTo(x=2360, y=60) time.sleep(.5) pyauto.click(x=2360, y=60) time.sleep(.5) #Paste to Member Details/Member Info Column C Last Row + 1 if rename_loc: md_info.range(f"C{mdnlr + 1}").value = "***Review User Name***" else: md_info.range(f"C{mdnlr + 1}").value = pyclip.paste()