Example #1
0
 def test_info(self):
     self.assertFalse(self.r.contains(lackey.Location(-5, -5)))
     new_region = lackey.Region(-10, -10, 5, 5)
     self.assertFalse(self.r.contains(new_region))
     with self.assertRaises(TypeError):
         self.r.contains("werdz")
     self.r.hover()
     self.assertTrue(self.r.containsMouse())
Example #2
0
def initGlobalRegion(uiaRect):
    global WORK_AREA
    left = uiaRect.left
    top = uiaRect.top
    width = uiaRect.right - uiaRect.left
    height = uiaRect.bottom - uiaRect.top
    WORK_AREA = lackey.Region(left, top, width, height)
    logging.info('Working area is (%d,%d,%d,%d)' % (left, top, width, height))
Example #3
0
 def test_constructor(self):
     self.assertIsInstance(lackey.Region(self.r), lackey.Region)
     self.assertIsInstance(lackey.Region((0, 0, 5, 5)), lackey.Region)
     self.assertIsInstance(lackey.Region(0, 0), lackey.Region)
     self.assertIsInstance(lackey.Region(0, 0, 10, 10, 3), lackey.Region)
     with self.assertRaises(TypeError):
         lackey.Region("foobar")
     with self.assertRaises(TypeError):
         lackey.Region()
     self.assertIsInstance(
         lackey.Region.create(lackey.Location(0, 0), 5, 5), lackey.Region)
     self.assertIsInstance(
         lackey.Region.create(lackey.Location(0, 0),
                              lackey.Region.CREATE_X_DIRECTION_RIGHT,
                              lackey.Region.CREATE_Y_DIRECTION_BOTTOM, 10,
                              10), lackey.Region)
     self.assertIsInstance(
         lackey.Region.create(lackey.Location(10, 10),
                              lackey.Region.CREATE_X_DIRECTION_LEFT,
                              lackey.Region.CREATE_Y_DIRECTION_TOP, 10, 10),
         lackey.Region)
Example #4
0
def getArea(imgName):
    match = WORK_AREA.exists(imgName)
    if match != None and match.getScore() >= DEFAULT_SIMILARITY_THRESHOLD:
        return match
    else:
        return lackey.Region(0, 0, 0, 0)
Example #5
0
@Author		: Wang.Yu
@Version	: 1.0
@Contact	: [email protected]
@License	: (C)Copyright 2021, Personal exclusive right.
'''
import pdb
import logging
import time
import win32gui
import win32con
import win32print
import lackey

TIMEOUT_LIMIT = 80  # 8s
WORK_AREA = lackey.Region(
    0, 0, win32print.GetDeviceCaps(win32gui.GetDC(0), win32con.DESKTOPHORZRES),
    win32print.GetDeviceCaps(win32gui.GetDC(0),
                             win32con.DESKTOPVERTRES))  # (x, y, w, h = args)
DEFAULT_SIMILARITY_THRESHOLD = 0.85


# init screen scope
def initGlobalRegion(uiaRect):
    global WORK_AREA
    left = uiaRect.left
    top = uiaRect.top
    width = uiaRect.right - uiaRect.left
    height = uiaRect.bottom - uiaRect.top
    WORK_AREA = lackey.Region(left, top, width, height)
    logging.info('Working area is (%d,%d,%d,%d)' % (left, top, width, height))

Example #6
0
try:
    state = True
    while state:
        p=p+1 
        prog_state = True
        while prog_state:
            im = pg.screenshot()
            pix = im.getpixel((x_pix, y))
            pg.scroll(-1)
            #print (pix)
            if pix == (235, 237, 240):
                prog_state = False
            png_name = str(p)
            read_png = png_name + '.png'
            print(type(read_png))
            i = lackey.Region (x_rgn, y, w_rgn, h_rgn)
            i.saveScreenCapture(path= 'C:\\Users\\HRK\\Documents\\vscode', name = png_name)
            img = cv2.imread(read_png)
            text = pytesseract.image_to_string(img)
            #x = type(text)
            #print(x)
            #print(text)
            name = text.split("\n")[0]
            print(name.ljust(35), end= '')
            #li= list(str.split(text))
            #print (li)
            numbers = [int(word) for word in text.split() if word.isdigit()]
            #print(numbers)
            j = [str(integer) for integer in numbers]
            k_string = "".join(j)
            if k_string == '':