Search code examples
python-3.ximage-processingpyautogui

how to extracts icons positions from desktop screenshot in python


I want to extract coordinates of theses icon ,How can I do this using python Any help will be appreciated enter image description here

Thank you


Solution

  • Does it help you?

    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))
    

    Each icon needs on your screen 51 pixels in width and 56 pixels in height. In addition, consider the distance to the first row of 4 pixels and between the rows of 11 pixels. I've added a pixel to x and y so that you can get to the next icon.