python 如何从桌面截图中提取图标位置

how to extracts icons positions from desktop screenshot in python

我想提取这些图标的坐标,如何使用 python 任何帮助将不胜感激enter image description here

谢谢

对你有帮助吗?

def get_pos_x(col):
    return (col - 1) * 51 + 1

def get_pos_y(row):
    return 4 + (row - 1) * 56 + (row - 1) * 11 + 1

icon = (51, 56) # width * height

col = 2
row = 2

print(get_pos_x(col))
print(get_pos_y(row))

屏幕上的每个图标需要 51 像素宽和 56 像素高。此外,还要考虑到第一行 4 个像素和每行 11 个像素之间的距离。我在 x 和 y 上添加了一个像素,以便您可以转到下一个图标。