
# https://www.globalsino.com/ICs/page4853.html
# Find a similar feature and then click it.

import pyautogui as pg
import time

print(pg.position())

time.sleep(2)

MySearch_img = pg.locateAllOnScreen(r'C:\GlobalSino\ICs\images\4600Chrome0.PNG',
                                    grayscale = 'True', confidence =0.8)
if len(list(MySearch_img)) != 0:
    def MySearch():
        MySearch_img_b = pg.locateAllOnScreen(r'C:\GlobalSino\ICs\images\4600Chrome0.PNG',
                                            grayscale = 'True', confidence =0.8)

        for element in MySearch_img_b:
            pg.click(element)
        pg.hotkey('ctrl','t')
        # Open the page of the downloaded list
        pg.hotkey('ctrl', 'j')

    # The click will be on the first screen if there are two screens for a PC
    MySearch()
    
else:    
    time.sleep(2)
    pg.hotkey('winleft')

    time.sleep(2)
    pg.typewrite('chrome\n', 0.5)
