Reputation: 53
I'm creating a bot to help me with a certain task. It retrieves data from a spreadsheet, turns it into a list and then it feeds a for loop with my actions.
However despite trying multiple ways to speed up the task, theres still a delay of about 3-5 seconds betweeen each action (click/type).
My function is the following:
def fat(wagon_number, wagon_weight):
pyautogui.doubleClick(-1365, 361)
pyautogui.write(wagon_number)
pyautogui.PAUSE = 3.0
pyautogui.click(-1020, 360)
pyautogui.click(-891, 375)
pyautogui.write(wagon_weight)
pyautogui.click(-973, 472)
pyautogui.click(-872, 342)
pyautogui.write('1')
pyautogui.click(-826, 338)
pyautogui.write('1')
pyautogui.click(-700, 342)
pyautogui.press('enter')
pyautogui.click(-619, 343)
pyautogui.write(wagon_weight)
pyautogui.click(-541, 343)
pyautogui.write(wagon_weight)
pyautogui.click(-840, 388)
pyautogui.write('1')
pyautogui.click(-760, 388)
pyautogui.write('1')
pyautogui.click(-686, 388)
pyautogui.write('123544')
pyautogui.click(-743, 757)
pyautogui.click(-766, 675)
This function is called by the following code:
#data retrieve
file_location = 'my file.xlsx'
df = pd.read_excel(fr'{file_location}', dtype={'Name': str, 'Value': str})
wagon_list = df['Wagon'].tolist()
weight_list = df['Weight'].tolist()
for i in range(0, 10): #my range range is set based on the list lenght but I lost this part
wagon = str(wagon_list[counter_0])
weight = str(weight_list[counter_0])
fat(wagon, weight)
counter_0 += 1
choice = input("Do you wanna continue? Type "y" or "n": \n")
if choice == "n":
break
else:
continue
How can I speed up the time between each mouse movement+click?
Upvotes: 1
Views: 711
Reputation: 53
Like Matiiss said, using pyautogui.pause(3), it sets the time between actions as 3s rather than pausing the code for 3s (thats what I meant).
Upvotes: 2