(Apr-17-2022, 05:36 AM)bowlofred Wrote: [ -> ]You didn't make the change everywhere, and you didn't show the full traceback to see which line caused it. I'm presuming that line 86 is now working, but 88 or 96 is now generating the error.
86 is still producing the error:
Error:
Traceback (most recent call last):
File "/Volumes/PortableSSD/untitled_folder/imagefinder.py", line 86, in <module>
isburger = pyautogui.locateOnScreen('singleburger.png', region=(xregion, yregion, length, height))
File "/Users/dude8074/Library/Python/3.8/lib/python/site-packages/pyautogui/__init__.py", line 175, in wrapper
return wrappedFunction(*args, **kwargs)
File "/Users/dude8074/Library/Python/3.8/lib/python/site-packages/pyautogui/__init__.py", line 213, in locateOnScreen
return pyscreeze.locateOnScreen(*args, **kwargs)
File "/Users/dude8074/Library/Python/3.8/lib/python/site-packages/pyscreeze/__init__.py", line 360, in locateOnScreen
retVal = locate(image, screenshotIm, **kwargs)
File "/Users/dude8074/Library/Python/3.8/lib/python/site-packages/pyscreeze/__init__.py", line 340, in locate
points = tuple(locateAll(needleImage, haystackImage, **kwargs))
File "/Users/dude8074/Library/Python/3.8/lib/python/site-packages/pyscreeze/__init__.py", line 259, in _locateAll_python
haystackImage = haystackImage.crop((region[0], region[1], region[0] + region[2], region[1] + region[3]))
TypeError: can only concatenate str (not "int") to str
with this script:
import pyautogui
import time
import PIL
regionx = 0
regiony = 0
length = 1920
height = 1080
pyautogui.alert("Please put you cursor over the single burger selection button within 5 seconds of pressing OK")
time.sleep(5)
bplain = pyautogui.position()
print("single burger button position captured")
pyautogui.alert("Position captured. Press OK to continue calibration. Do not move your character or adjust your camera zoom.")
pyautogui.alert("Please put you cursor over the double burger selection button within 5 seconds of pressing OK")
time.sleep(5)
bdouble = pyautogui.position()
print("double burger button position captured")
pyautogui.alert("Position captured. Press OK to continue calibration. Do not move your character or adjust your camera zoom.")
pyautogui.alert("Please put you cursor over the lettuce burger selection button within 5 seconds of pressing OK")
time.sleep(5)
blettuce = pyautogui.position()
print("lettuce burger button position captured")
pyautogui.alert("Position captured. Press OK to continue calibration. Do not move your character or adjust your camera zoom.")
pyautogui.alert("Please put you cursor over the bloxy cola selection button within 5 seconds of pressing OK")
time.sleep(5)
cola = pyautogui.position()
print("cola button position captured")
pyautogui.alert("Position captured. Press OK to continue calibration. Do not move your character or adjust your camera zoom.")
pyautogui.alert("Please put you cursor over the fries selection button within 5 seconds of pressing OK")
time.sleep(5)
fries = pyautogui.position()
print("fries button position captured")
pyautogui.alert("Position captured. Press OK to continue calibration. Do not move your character or adjust your camera zoom.")
pyautogui.alert("Put your cursor over the upper left corner of a customer's speech bubble within 5 seconds of pressing OK. Do not let the cash register images get in the box.")
time.sleep(5)
topleft = pyautogui.position()
print("top left is captured")
pyautogui.alert("Position captured. Press OK to continue calibration. Do not move your character or adjust your camera zoom.")
pyautogui.alert("Put your cursor over the bottom right corner of a customer's speech bubble within 5 seconds of pressing OK. Do not let the cash register images get in the box.")
time.sleep(5)
btmrght = pyautogui.position()
print("bottom right is captured")
selection = pyautogui.alert("Calibration is complete. Please finish the current customer's order (if there is one) before pressing OK.")
## Finding the region of selection:
topleftstr = str(topleft)
btmrghtstr = str(btmrght)
topleftList = topleftstr.split(sep=", y=", maxsplit = 2)
endregionList = btmrghtstr.split(sep=", y=",maxsplit = 2)
print(str(topleftList))
print(str(endregionList))
regionx,regiony = topleftList
endregionx,endregiony = endregionList
regionxfixed = regionx.split(sep="=",maxsplit=2)
endregionxfixed = endregionx.split(sep="=",maxsplit=2)
regionyfixed = regiony.split(sep=")",maxsplit=2)
endregionyfixed = endregiony.split(sep=")",maxsplit=2)
nox,xregion = regionxfixed
print(xregion)
nox2,endxregion = endregionxfixed
print(endxregion)
yregion,noy = regionyfixed
print(xregion)
endyregion,noy2 = endregionyfixed
print(endxregion)
length = int(endxregion) - int(xregion)
height = int(endyregion) - int(yregion)
time.sleep(3)
##while True:
if True:
isburger = pyautogui.locateOnScreen('singleburger.png', region=(xregion, yregion, length, height))
if isburger == "ImageNotFoundException":
isdburger = pyautogui.locateOnScreen('doubleburger.png', region=(xregion, yregion, length, height))
if isdburger == "ImageNotFoundException":
pyautogui.leftClick(blettuce)
else:
pyautogui.leftClick(bdouble)
else:
print("found single burger")
pyautogui.leftClick(bplain)
isCola = pyautogui.locateOnScreen('cola.png', region=(xregion, yregion, length, height))
if not isCola == "ImageNotFoundException":
print("found cola")
pyautogui.leftClick(cola)
isFries = pyautogui.locateOnScreen('fries.png', region=(xregion, yregion, length, height))
if not isFries == "ImageNotFoundException":
print("found fries")
pyautogui.leftClick(x=599, y=537)
time.sleep(5)
I'm thinking its probably an error with my math to calculate
xregion
,
yregion
,
length
, and
height
.