def moveToFletchingOptions(item): cwd = os.getcwd() rsx, rsy = RS.position() #gets position of RS window #x = rsx + random.randint(23,167)#x coord range of short bow #y = rsy + random.randint(397,469) #y respectivaly x, y = Mouse.genCoords(206, 225, 221, 266) Mouse.moveClick(x, y, 3) #right-clicks on short bow #taking away rs position since getoptionsmenu func adds them back in x = x - rsx y = y - rsy #gets screenshot menu_x, menu_y, menu = RS.getOptionsMenu(x, y) loc, w, h = Match.this(menu, cwd + '/imgs/makeX.png') #runs though the imgae to find it and click it for pt in zip(*loc[::-1]): pt_x, pt_y = pt #unpackes the pt into x,y x_a = menu_x + pt_x + (random.randint(1, (w * 2))) y_a = menu_y + pt_y + (random.randint(5, h)) #moves to 'Make X' Mouse.moveTo(x_a, y_a) #clicks on 'Make X' Mouse.click(1) RandTime.randTime(1, 5, 0, 1, 9, 9) Keyboard.type_this("99") Keyboard.press('enter') break
def moveToFletchingOptions(item): cwd = os.getcwd() rsx, rsy = RS.position() #gets position of RS window #x = rsx + random.randint(23,167)#x coord range of short bow #y = rsy + random.randint(397,469) #y respectivaly x,y = Mouse.genCoords(206,225,221,266) Mouse.moveClick(x,y,3) #right-clicks on short bow #taking away rs position since getoptionsmenu func adds them back in x = x - rsx y = y - rsy #gets screenshot menu_x, menu_y, menu = RS.getOptionsMenu(x,y) loc, w, h = Match.this(menu, cwd+'/imgs/makeX.png') #runs though the imgae to find it and click it for pt in zip(*loc[::-1]): pt_x, pt_y = pt #unpackes the pt into x,y x_a = menu_x + pt_x + (random.randint(1,(w*2))) y_a = menu_y + pt_y + (random.randint(5,h)) #moves to 'Make X' Mouse.moveTo(x_a,y_a) #clicks on 'Make X' Mouse.click(1) RandTime.randTime(1,5,0,1,9,9) Keyboard.type_this("99") Keyboard.press('enter') break
def findOptionClick(self, x,y,option_name): #Mouse.moveClick(x, y, 3) print(f"Right-Clicking:x{x} y:{y}") self.hc.move((x,y),1) Mouse.click('right') RandTime.randTime(1,0,0,1,9,9) """Option name of in Image database only needs to be passed, x,y are obsoleate""" from modules import Imgdb # Image DB idb = Imgdb.ImgDb() #name of option loaded from image db template = idb.pickled_dict[option_name] # turning template to graysacle if RBG if len(template.shape) == 3: template = cv2.cvtColor(template,cv2.COLOR_RGB2GRAY) # getting w and h for generating random coords in range template_w, template_h = template.shape[::-1] rs_window, x, y = self.getPlayingScreen('gray') res = cv2.matchTemplate(rs_window,template,cv2.TM_CCOEFF_NORMED) threshold = 1 # Store the coordinates of matched area in a numpy array loc = np.where( res >= threshold) # clicks on option here when found in pattern for pt in zip(*loc[::-1]):#goes through each found image # Draw a rectangle around the matched region. # cv2.rectangle(rs_window, pt, (pt[0] + template_w, pt[1] + template_h), (0,255,255), 2) # creates list of possible coords ptx = [i for i in range(pt[0]+5, pt[0] + template_w)] pty = [i for i in range(pt[1]+5, pt[1] + template_h)] # chooses a single coords from the list ptx = random.choice(ptx) pty = random.choice(pty) print(f"ptx{ptx} pty{pty}") # debug ### #cv2.imshow('img', rs_window) #cv2.waitKey(5000) #cv2.destroyAllWindows() # range of x and y to click on. # in the options #Mouse.randMove(x,y1,x+(w/2),y2, 1) #ptx, pty = Mouse.randCoord(pt, template_w, template_h) #Mouse.moveClick(ptx,pty, 1) self.hc.move((ptx,pty),1) self.hc.click() RandTime.randTime(1,0,0,2,9,9) break
def moveToFletchingOptions(bow): cwd = os.getcwd() rsx, rsy = RS.position() #gets position of RS window #x = rsx + random.randint(23,167)#x coord range of short bow #y = rsy + random.randint(397,469) #y respectivaly if 'magic' in bow: x,y = Mouse.genCoords(350,405,450,456) x += rsx y += rsy elif 'yew' in bow or 'maple' in bow: x = rsx + random.randint(290,338)#x coord range of long bow. Defautl 209,299 y = rsy + random.randint(405,466) #BR-coord of longbow. Default: 395,456 Mouse.moveClick(x,y,3) #right-clicks on short bow #taking away rs position since getoptionsmenu func adds them back in x = x - rsx y = y - rsy #gets screenshot menu_x, menu_y, menu = RS.getOptionsMenu(x,y) loc, w, h = Match.this(menu, cwd+'/imgs/makeX.png') #runs though the imgae to find it and click it for pt in zip(*loc[::-1]): pt_x, pt_y = pt #unpackes the pt into x,y x_a = menu_x + pt_x + (random.randint(1,(w*2))) y_a = menu_y + pt_y + (random.randint(5,h)) #moves to 'Make X' Mouse.moveTo(x_a,y_a) #clicks on 'Make X' Mouse.click(1) RandTime.randTime(1,5,0,1,9,9) Keyboard.type_this("99") Keyboard.press('enter') break