Python Forum

Full Version: loop in pyautogui (python automation GUI application)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HI!I'm working on automation with my "exceldata to GUI app import". It goes quite well, but I have an issue with loop. When I'm looping, it imports data good in textboxes and with 'tab' it moves trough another textboxes very smooth. But loop stops at the end of the first row. it looks like my loop is not going through the whole excel file. What I need: import data from one row to textboxes, confirm this with entering, and repeat in other rows

here's my code:

wb = openpyxl.load_workbook('test.xlsx')
sheet = wb.active
max_row = sheet.max_row
max_column = sheet.max_column

def start_program():
    pyautogui.hotkey('win','r')
    pyautogui.typewrite(r"C:\Users\User\Desktop\GUITEST.lnk")
    pyautogui.hotkey('enter')
    pyautogui.sleep(3)

def loop_excel_sheet():
    for i in range(107, max_row+1):
        for j in range(1, max_column+1):
            cell_obj = sheet.cell(row=i, column=j)
            pyperclip.copy(str(cell_obj.value))
            pyautogui.typewrite(pyperclip.paste())
            pyautogui.hotkey('tab')

start_program()
loop_excel_sheet()