Python 3.x 使用autopy将光标移动到图像时出现问题

Python 3.x 使用autopy将光标移动到图像时出现问题,python-3.x,autopy,Python 3.x,Autopy,我正在学习尸检,希望能在这里找到帮助。 我试图在屏幕上找到一个图像并将光标移动到它 我编写了以下代码: import autopy # Take a screenshot of the entire desktop autopy.bitmap.capture_screen().save('screen.png') # define a function to search for the image in the screenshot def find_image_example():

我正在学习尸检,希望能在这里找到帮助。 我试图在屏幕上找到一个图像并将光标移动到它

我编写了以下代码:

import autopy
# Take a screenshot of the entire desktop
autopy.bitmap.capture_screen().save('screen.png')

# define a function to search for the image in the screenshot
def find_image_example():
    aid = autopy.bitmap.Bitmap.open('aid.png') # searched image
    screen = autopy.bitmap.Bitmap.open('screen.png') # Desktop screenshot

    pos = screen.find_every_bitmap(aid,0.1) # find the image if any

    if pos:
        print('Found aid at: %s' % str(pos)) # print all found instances
        x = pos[0][0] # x pos
        y = pos[0][1] # y pos
        print(x) # print for debug
        print(y) # print for debug
        autopy.mouse.smooth_move(x,y) # move the cursor to the first image
    else:
        print('no images found!') # print if no images found
# execute the function
find_image_example()
运行代码后,我收到以下错误消息:

    Found aid at: [(405.0, 1000.0), (552.0, 1000.0), (699.0, 1000.0)]
405.0
1000.0
  File "C:/Users/Mortada/PycharmProjects/autopy_tut/main.py", line 22, in <module>
    find_image_example()
  File "C:/Users/Mortada/PycharmProjects/autopy_tut/main.py", line 18, in find_image_example
    autopy.mouse.smooth_move(x,y) # move the cursor to the first image
ValueError: Point out of bounds
在以下位置找到帮助:[(405.0,1000.0)、(552.0,1000.0)、(699.0,1000.0)]
405
1000
文件“C:/Users/Mortada/PycharmProjects/autopy_tut/main.py”,第22行,在
查找\u图像\u示例()
文件“C:/Users/Mortada/PycharmProjects/autopy_tut/main.py”,第18行,在find_image_示例中
自动剖检。鼠标。平滑移动(x,y)#将光标移动到第一个图像
ValueError:点超出范围
我不确定这里出了什么问题:-/我以为我做对了,哈哈


我正在尝试复制此代码,但在我的
pos
变量中没有任何内容:(.你能分享aid.png文件吗?更新:我让它工作得很好,所以代码是正确的。如果看不到更多的信息,比如你的脚本截图,就很难调试。这是一个很酷的库,由于这个问题,我学到了一些新的东西:)@LuRsT true这确实是一个很好的:-)我已经添加了屏幕,我测试了一下,发现了同样的错误,但这是因为我的屏幕比你的小,所以我将图像的大小调整到了一半,脚本正常工作。你是不是碰巧用了两台显示器?你是在mac电脑上运行的?在dpi高的屏幕上,尸检似乎无法正常工作