def identify_pic(region=None):
     
     
     loc = snp.locateOnScreen('0.png',region=region,threshold=0.9) 
     num=0
     if loc ==None:
         loc = snp.locateOnScreen('1.png',region=region,threshold=0.5)
         num=1
     if loc ==None:
         loc = snp.locateOnScreen('2.png',region=region,threshold=0.8)
         num=2
     if loc ==None:
         loc = snp.locateOnScreen('8.png',region=region,threshold=0.8)
         num=8
     if loc ==None:
         loc = snp.locateOnScreen('3.png',region=region,threshold=0.7)
         num=3
     if loc ==None:
         loc = snp.locateOnScreen('4.png',region=region,threshold=0.5)
         num=4
     if loc ==None:
         loc = snp.locateOnScreen('5.png',region=region,threshold=0.8)
         num=5
     if loc ==None:
         loc = snp.locateOnScreen('6.png',region=region,threshold=0.8)
         num=6
     if loc ==None:
         loc = snp.locateOnScreen('7.png',region=region,threshold=0.7)
         num=7
     
     if loc ==None:
         loc = snp.locateOnScreen('9.png',region=region,threshold=0.8)
         num=9
     if loc == None:
         num=0   #沒有數字
             
     return loc,num
Example #2
0
        eel -= 2

    gui.click(sushi_done_x, sushi_done_y, pause=2, _pause=True)


###########################   main    #############################

# enter game
click_center('sushi/play.png')
time.sleep(0.2)
click_center('sushi/go.png')
time.sleep(0.2)

# init position
print('calculating position')
top = snp.locateOnScreen('sushi/music.png')
phone = snp.locateCenterOnScreen('sushi/phone.png')
ingredient_x = top[0] + 20
ingredient_y = top[1] + 330
sushi_done_x = top[0] + 270
sushi_done_y = top[1] + 395

customer_y = top[1] + 40
customer_pos = []
customer_pos.append(top[0] + 60)
customer_pos.append(top[0] + 180)
customer_pos.append(top[0] + 310)
customer_pos.append(top[0] + 430)
customer_pos.append(top[0] + 550)

# start game
@author: LOVESS
"""

import pyautogui #鍵盤滑鼠的操作
import snp
import time
pyautogui.FAILSAFE = True

pyautogui.PAUSE = 1  #太快無法執行
pyautogui.hotkey('win','r')
pyautogui.press('shift') #如果會卡中文輸入法的
pyautogui.typewrite('chrome',0.1)
pyautogui.press('enter')

pyautogui.PAUSE = 1  #太快無法執行
loc = snp.locateOnScreen('ENGLISH.png',region=(1184,732,19,31),threshold=0.9) 
if loc == None:
    pyautogui.press('shift') #如果會卡中文輸入法的
    
pyautogui.typewrite('https://gamekuo.com/html5/3963_math-genius-games',0.1)

loc = snp.locateOnScreen('winup.png',region=(1278,6,36,18)) 
if loc == None:
    pyautogui.click(1335,67)
#pyautogui.hotkey('win','up') #視窗最大化
    
pyautogui.press('enter')
pyautogui.PAUSE = 1  #太快無法執行


pyautogui.moveTo(739,462) #滑鼠移到適當位置進行滾動
Example #4
0
def wait_pic(name, region=None):
    loc = snp.locateOnScreen(name, region=region)
    while loc == None:
        loc = snp.locateOnScreen(name, region=region)
    return loc
Example #5
0
def getOther(pic):
    return snp.locateOnScreen(pic,
                              region=(pos[0] + pos[2] + 50, pos[1] - 20, 130,
                                      pos[3] + 10))
Example #6
0
def getThing(pic):
    thing = snp.locateOnScreen(pic,
                               threshold=0.6,
                               region=(pos[0] + pos[2] + 20, pos[1] - 20, 100,
                                       pos[3] + 10))
    return thing
Example #7
0
def getOther(pic):
    return snp.locateOnScreen(pic,
                              region=(pos[0] + pos[2] + 50, pos[1] - 20, 130,
                                      pos[3] + 10))


def getThing(pic):
    thing = snp.locateOnScreen(pic,
                               threshold=0.6,
                               region=(pos[0] + pos[2] + 20, pos[1] - 20, 100,
                                       pos[3] + 10))
    return thing


# find dino position
pos = snp.locateOnScreen('dino.png')
if (pos == None):
    print('dion not found')
    exit()
gui.click(pos[0] + pos[2] + 150, pos[1] - 20)

# start game
gui.press('space')
while True:
    if snp.locateOnScreen('over.png',
                          region=(pos[0] + pos[2] + 150, pos[1] - 50, 200,
                                  40)):
        break
    if getThing('bird.png') or getThing('cactus.png') or getThing(
            'cactus_s.png'):
        gui.press('space')
    'microsoft-edge:https://gamekuo.com/html5/3963_math-genius-games')
pyautogui.PAUSE = 1
pyautogui.press('enter')
pyautogui.PAUSE = 2
# to full screen
pyautogui.keyDown('alt')
pyautogui.press(' ')
pyautogui.press('x')
pyautogui.keyUp('alt')
pyautogui.moveTo(400, 300)
pyautogui.scroll(-300)
pyautogui.PAUSE = 2

region = (400, 300, 800, 450)
# skip video ad
p = snp.locateOnScreen('pic\skipAd_button.JPG')
if p != None:
    print('found skipAd_button')
    pyautogui.click(p[0] + p[2] // 2, p[1] + p[3] // 2)

images = glob.glob("pic/numbers/*.JPG")
equal_pic = cv2.imread("pic/equal.JPG")
answer_box_pic = cv2.imread("pic/answer_box.JPG")
results_pic = cv2.imread("pic/results.JPG")

img_array = []
for img in images:
    image = cv2.imread(img)
    img_array.append(image)

region_play_button = (600, 500, 450, 450)