def clickToArea(self, autoObject): area1 = areaStrToList(autoObject.area1) x = int((area1[0] + area1[2]) / 2) y = int((area1[1] + area1[3]) / 2) pyautogui.moveTo(x, y) pyautogui.click() time.sleep(0.5)
def clc_btnGrabArea1(self): lst = areaStrToList(self.txtArea1.text()) img_grab = ImageGrab.grab(bbox=(lst[0], lst[1], lst[2], lst[3])) img_save = cv2.cvtColor(np.array(img_grab), cv2.COLOR_RGB2BGR) # pylint: disable=no-member name = "img\\"+self.txtName.text()+".jpg" print(name) cv2.imwrite(name, img_save) # pylint: disable=no-member print("grab")
def _commandHarvestMoveSlider(self): find, point = self.engine.getAreaCoordByName("btnHarverWoodSlider") if find: isObj, autoObject = self.engine.getAutoObjectByName( "btnHarverWoodSlider") if isObj: area2 = areaStrToList(autoObject.area2) moveFX = point[0] + area2[0] moveFY = point[1] + area2[1] pyautogui.moveTo(moveFX, moveFY) pyautogui.drag(area2[2] - moveFX, 0, 1, button='left') time.sleep(0.2)
def _commandSleepMoveSlider(self): find, point = self.engine.getAreaCoordByName("btnSleepSlider") if find: print("Sleep find: " + str(self.countSleepDays) + " Point0:" + str(point[0]) + " Point1:" + str(point[1])) isObj, autoObject = self.engine.getAutoObjectByName( "btnSleepSlider") if isObj: area2 = areaStrToList(autoObject.area2) moveFX = point[0] + area2[0] moveFY = point[1] + area2[1] pyautogui.moveTo(moveFX, moveFY) pyautogui.drag(area2[2] - moveFX, 0, 1, button='left') time.sleep(0.2) else: print("Sleep no find: " + str(self.countSleepDays))
def getText(self, autoObject): area1 = areaStrToList(autoObject.area1) screenshot = np.array( ImageGrab.grab(bbox=(area1[0], area1[1], area1[2], area1[3]))) screenshot = cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY) # pylint: disable=no-member screenshot = cv2.bitwise_not(screenshot) # pylint: disable=no-member screenshot = cv2.threshold(screenshot, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1] # pylint: disable=no-member # _, screenshot = cv2.threshold(screenshot, 180, 255, cv2.THRESH_BINARY) screenshot = cv2.medianBlur(screenshot, 3) # pylint: disable=no-member # screenshot = cv2.resize(screenshot,(35,20)) # cv2.namedWindow('image') # pylint: disable=no-member # cv2.imshow("image", screenshot) # pylint: disable=no-member # return False return pytesseract.image_to_string( screenshot, config='--psm 6 -c tessedit_char_whitelist=0123456789')
def isArea(self, autoObject): fileName = "img\\" + autoObject.name + ".jpg" if not os.path.exists(fileName): print("no file: " + fileName) return False # area1 = areaStrToList(autoObject.area1) area2 = areaStrToList(autoObject.area2) # img_find_in = np.array(ImageGrab.grab(bbox=(area2[0],area2[1],area2[2],area2[3]))) screenshot = ImageGrab.grab(bbox=(area2[0], area2[1], area2[2], area2[3])) img_find_in = np.array(screenshot.getdata(), dtype='uint8').reshape( (screenshot.size[1], screenshot.size[0], 3)) img_find_what = cv2.imread(fileName, 0) # pylint: disable=no-member points = self.find_patt(img_find_in, img_find_what, 0.60) pointsl = list(points) return len(pointsl) != 0
def clc_btnArea2(self): self.txtArea2.setText(str(GetArea().getArea(areaStrToList(self.txtArea2.text()))))