Likely I am doing something wrong here, but this snippet:
screen_size = pyautogui.size()
pos_local = imagesearch("./Local.png")
if pos_local[0] != -1:
print("pos_local : ", pos_local[0], pos_local[1])
else:
print("image not found")
print("inputs to imagesearch area: ",pos_local[0] - 50, pos_local[1] -50, pos_local[0]+200, screen_size[1]-50)
pos = imagesearcharea("./win-bottom-strip.png", 3416, 399, 3666, 2110, 0.9)
if pos[0] != -1:
print("position : ", pos[0], pos[1])
else:
print("image not found")
produces this output + exception:
pos_local : 3466 449
inputs to imagesearch area: 3416 399 3666 2110
Traceback (most recent call last):
File "\findMoveWin.py", line 45, in
pos = imagesearcharea("./win-bottom-strip.png", pos_local[0] - 50, pos_local[1] -50, pos_local[0]+200, screen_size[1]-50)
File "C:\Program Files\Python39\lib\site-packages\python_imagesearch\imagesearch.py", line 60, in imagesearcharea
im = region_grabber(region=(x1, y1, x2, y2))
File "C:\Program Files\Python39\lib\site-packages\python_imagesearch\imagesearch.py", line 36, in region_grabber
return sct.grab(region)
File "C:\Program Files\Python39\lib\site-packages\mss\base.py", line 88, in grab
return self._grab_impl(monitor)
File "C:\Program Files\Python39\lib\site-packages\mss\windows.py", line 264, in _grab_impl
self.data = ctypes.create_string_buffer(width * height * 4) # [2]
File "C:\Program Files\Python39\lib\ctypes_init.py", line 63, in create_string_buffer
buftype = c_char * init
ValueError: Array length must be >= 0, not -16615168
These work fine:
pos = imagesearcharea("./win-bottom-strip.png", 0,0,100,100)
pos = imagesearcharea("./win-bottom-strip.png", 100,220,2000,2000)
pos = imagesearcharea("./win-bottom-strip.png", 0,0,screen_size[0],screen_size[1])
pos = imagesearcharea("./win-bottom-strip.png", 0, 0, screen_size[0],screen_size[1])
pos = imagesearcharea("./win-bottom-strip.png", 100,0,2000,2160)
This fails with a different exception:
(note only diff is X1 = 1,000 when fail and x1 = 100 when ok)
pos = imagesearcharea("./win-bottom-strip.png", 1000,0,2000,2160)
screeb_size: Size(width=3840, height=2160)
Traceback (most recent call last):
File "D:\dev\eve\eve-scan\src\findMoveWin.py", line 55, in
pos = imagesearcharea("C:/Users/d/OneDrive/Personal/misc-docs/eve/scan-images/win-bottom-strip.png", 1000,0,2000,2160)
File "C:\Program Files\Python39\lib\site-packages\python_imagesearch\imagesearch.py", line 60, in imagesearcharea
im = region_grabber(region=(x1, y1, x2, y2))
File "C:\Program Files\Python39\lib\site-packages\python_imagesearch\imagesearch.py", line 36, in region_grabber
return sct.grab(region)
File "C:\Program Files\Python39\lib\site-packages\mss\base.py", line 88, in grab
return self._grab_impl(monitor)
File "C:\Program Files\Python39\lib\site-packages\mss\windows.py", line 285, in _grab_impl
raise ScreenShotError("gdi32.GetDIBits() failed.")
mss.exception.ScreenShotError: gdi32.GetDIBits() failed.
Please advise?