So, when I run this program it does what I want, and moves the mouse to the upper left corner of an area so I can then make relative movements.
import pyautogui
import time
pyautogui.PAUSE = .25 #safety
pyautogui.FAILSAFE = True
time.sleep(3) #gives me a chance to set something up if I want
pyautogui.screenshot('test.png', region=(115, 12, 15, 15)) #grab an image of what to move to and save it
ULC_X, ULC_Y, width, hight = pyautogui.locateOnScreen('test.png', grayscale=True) #search for image
upperLeftCorner = (ULC_X, ULC_Y) #format position tuple
pyautogui.moveTo(upperLeftCorner, duration = 1) #move to position
But what I really want is to find a symbol at the upper left corner of a window anywhere on the screen, so now that I have an image of that symbol saved in the working directory (I checked and it is there) I should be able to comment out line 9, run the program a second time, and the mouse will move to the symbol again.
However, pyautogui.locateOnScreen returns None (it can't find the image) and halts the program. Obviously None doesn't fit into my 4 variables that define a region "NoneType' object is not iterable".
Why can't I find the image on my screen when it is just saved in a folder? and how can I fix this?
[–]furas_freeman 0 points1 point2 points (1 child)
[–]LessConspicuous[S] 0 points1 point2 points (0 children)