Reputation: 251
I have the following code:
b_counter = False
while (b_counter == False):
if (pyautogui.locateOnScreen('editcheck.png') is not None):
pyautogui.click(pyautogui.center(pyautogui.locateOnScreen('home.png')))
b_counter = True
The loop lags when running, sometimes up to 10 seconds after the image has loaded. My machine itself is pretty fast (i7 16gb ram etc). Is there any way to speed up this loop?
I'm loading webpages so the "home" buttons do not appear immediately. This loop occurs after pyautogui has entered in the web address to load.
Upvotes: 1
Views: 10023
Reputation: 631
simple way
if (pyautogui.locateOnScreen('test.PNG') is not None):
pyautogui.hotkey('win', 'l')
Upvotes: 2
Reputation: 251
Found an answer to my question. Select a region to make the search feature faster. This way, the program won't be searching through the whole screen, just a specific region.
ex:
import pyauotgui
pyautogui.locateOnScreen('test.png', region = (0,0,400,400))
where region = left, top, width, height
Upvotes: 5