Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
locateOnScreen Issues
#1
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()     
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyautogui.locateOnScreen producing error dude8074 6 6,407 Apr-17-2022, 05:05 PM
Last Post: bowlofred
  how to avoid reapiting lines with locateonscreen rachidel07 3 3,293 Feb-07-2021, 09:30 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020