Exemple #1
0
def main():
    repeat = 0
    keyPress.waitStart()
    while repeat < 99999999:
        1
        nextPiece = (0, 0, 0)
        im = quickGrab.screenGrab()
        nextPiece = im.getpixel(initPix)
        time.sleep(0.01)
        if (nextPiece == Oc):
            print('Oc')
            compareO()
        if (nextPiece == Lc):
            print('Lc')
            compareL()
        if (nextPiece == Jc):
            print('Jc')
            compareJ()
        if (nextPiece == Ic):
            print('Ic')
            compareI()
        if (nextPiece == Tc):
            print('Tc')
            compareT()
        if (nextPiece == Sc):
            print('Sc')
            compareS()
        if (nextPiece == Zc):
            print('Zc')
            compareZ()
        print('distribution:' + str(distribution) + '      Column Height: ' +
              str(colh))
        checkClear()
        updateColh()
def compareNoriOrderPixels():
    im = screenGrab()
    noriPixel = im.getpixel(Coords.t_Nori)

    if noriPixel == FoodOrderPixels.NoriAvailable:
        return True

    elif noriPixel == FoodOrderPixels.NoriUnavailable:
        return False

    else:
        print('Unknown pixelcolor at nori!!')
        print('Pixel received: ', noriPixel)
def compareRiceOrderPixels():
    im = screenGrab()
    ricePixel = im.getpixel(Coords.t_Rice)

    if ricePixel == FoodOrderPixels.RiceAvailable:
        return True

    elif ricePixel == FoodOrderPixels.RiceUnavailable:
        return False

    else:
        print('Unknown pixelcolor at rice!!')
        print('Pixel received: ', ricePixel)
def compareRoeOrderPixels():
    im = screenGrab()
    roePixel = im.getpixel(Coords.t_Roe)

    if roePixel == FoodOrderPixels.RoeAvailable:
        return True

    elif roePixel == FoodOrderPixels.RoeUnavailable:
        return False

    else:
        print('Unknown pixelcolor at Roe!!')
        print('Pixel received: ', roePixel)


# print(compareRoeOrderPixels())
optical argument for bbox with default as full screen

Task:

    1) Allow users to define an enemy 
    2) Search for define enemy on screenshot to get enemy coordinates
    3) Excute attacks 

Extra bits:
    1) add click option on maplewindow function 
"""
from PIL import ImageGrab
import os
import time
import pyautogui
import numpy as np
import cv2

from quickGrab import screenGrab

screencoord = (500, 500, 1000, 1000)

#last_time = time.time()
while True:
    printscreen = np.array(screenGrab(bbox = screencoord)) # RGB
    cv2.imshow('window', cv2.cvtColor(printscreen, cv2.COLOR_RGB2BGR))
#    print('Loop took {} seconds'.format(time.time() - last_time))
#    last_time = time.time()
    if cv2.waitKey(1) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break