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 skillHover(skill): """Hovers over passed skill from 1-5 secs""" #Coordinates of skill's button skills = { 'attack':0, 'hitpoints':0,'mining':0, 'strength':0,'agility':0,'smithing':0, 'defence':0,'herblore':(620,295,662,311),'fishing':0, 'ranged':0,'thieving':0,'cooking':0, 'prayer':0,'crafting':(621,358,664,373),'firemaking':0, 'magic':(557,388,602,402),'fletching':(620,389,666,406),'woodcutting':0, 'runecraft':0,'slayer':0,'farming':0, 'construction':0,'hunter':0 } x1,y1,x2,y2 =skills[skill] x,y = Mouse.genCoords(x1,y1,x2,y2) Mouse.moveTo(x,y) RandTime.randTime(1,0,0,5,9,9)
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 select(self, *args): try: buysell = args[0] item = args[1] except Exception as e: print(e) #Setting for Buying if buysell == 'buy': slots = self.get_slots(buysell) #Setting for Selling elif buysell == 'sell': slots = self.get_slots(buysell) else: print("Make a selection buy or sell") ## picks random slot from buy/sell slots n = random.randint(0, len(slots) - 1) ## combines coords pos = slots[n] x = pos[0] y = pos[1] ## adds randomness mx, my = self.add_randomness(17, x, y + 15) #pyautogui.moveTo(mx,my) Mouse.moveTo(mx, my) pyautogui.click() RandTime.randTime(0, 5, 7, 1, 9, 9) if buysell == 'buy': Keyboard.type_this(item) else: Keyboard.type_this(item)
def main(herb_object): # var to break out of loop after 3 bank tries bankchecking = 0 n_secs = 1 while True: if bankchecking == 5: break #open bank RS.open_cw_bank() #give time for window to open up time.sleep(1.2) #check if bank is open, if not end if not RS.isBankOpen(): bankchecking +=1 n_secs = n_secs * bankchecking time.sleep(n_secs) continue # resets bankchecking bankchecking = 0 #deposit all #if herb_object in inventory if not RS.isInvEmpty(): RS.depositAll() #loop makes sure herbs are withdrawn! while True: try: herbx,herby = findherb(herb_object) except Exception as e: print('No more herbs') print(e) return Mouse.moveClick(herbx,herby,3) # removes RS coords since added back in in findOptionClick herbx -= RSX herby -= RSY RS.findOptionClick(herbx,herby,'withdrawAll') time.sleep(.9) randTime(0,0,0,0,0,9) # breaks when items are taken out into inventory if not RS.isInvEmpty(): break else: # deposits all items from inventory x,y = Mouse.genCoords(RSX+13,RSY+60,RSX+500,RSY+352) Mouse.moveTo(x,y) #close bank RS.closeBank() find_grimmy_herbs_in_inventory(herb_object)
def find_template(template_name): #pass template to function global imd #checks to see wheater to add cur dir or not x1, y1 = RS.position() #Get runescapes top-left coords x1 += 557 #make The Bag's top-left, and btm-right coords y1 += 229 #x2,y2 == btm-right coord, width and height x2 = x1 + 173 y2 = y1 + 253 if not RS.is_button_selected('inventory'): #RS.press_button('inventory') init_x = random.randint(x1, x2) init_y = random.randint(y1, y2) Mouse.moveTo(init_x, init_y) autopy.key.tap(autopy.key.K_F1) # image of bag rs_bag = Screenshot.shoot(x1, y1, x2, y2) #Screenshot taken here, # cv2.imshow('bag', rs_bag) # cv2.waitKey(0) #template template = imd.pickled_dict[template_name] #imd.showImg('salmon') color_mode, w, h = template.shape[::-1] # change img to grayscale if color_mode == 3: template = cv2.cvtColor(template, cv2.COLOR_RGB2GRAY) res = cv2.matchTemplate(rs_bag, template, cv2.TM_CCOEFF_NORMED) threshold = .8 #default is 8 loc = np.where(res >= threshold) for pt in zip(*loc[::-1]): #goes through each found image btmX = pt[ 0] + w - 5 #pt == top-left coord of template, bottom-right point of of template image btmY = pt[1] + h - 5 #moving the pt coord of the template a bit to the right, so options menu get brought up pt = (pt[0] + 5, pt[1] + 2) x, y = gen_coords( pt, btmX, btmY ) #gets random x, y coords relative to RSposition on where to click #Mouse.moveClick(x,y, 3)#right clicks on given x,y coords # using new method to drop. holding shift autopy.key.toggle(autopy.key.K_SHIFT, True) Mouse.moveClick(x, y, 1) #right clicks on given x,y coords autopy.key.toggle(autopy.key.K_SHIFT, False) #RS.findOptionClick(x,y,'drop') RandTime.randTime(2, 0, 0, 2, 9, 9)
def skillsHover(rsx,rsy): """Hovers over n skills by n times""" n = random.randint(0,2) if n > 0: # Tuples of locations stats_btn = Mouse.genCoords(567,194,589,215) #Clicks the skills button Mouse.moveClick(stats_btn[0]+rsx,stats_btn[1]+rsy,1) for i in range(n): # x1 y1 x2 y2 stats_window = Mouse.genCoords(557,234,729,470) # Randomly hovers over a random skill Mouse.moveTo(stats_window[0]+rsx,stats_window[1]+rsy) RandTime.randTime(1,0,0,2,9,9)
def skillsHover(self, rsx,rsy): """Hovers over n skills by n times""" n = random.randint(0,2) if n > 0: # Tuples of locations stats_btn = Mouse.genCoords(567,194,589,215) #Clicks the skills button Mouse.moveClick(stats_btn[0]+rsx,stats_btn[1]+rsy,1) for i in range(n): # x1 y1 x2 y2 stats_window = Mouse.genCoords(557,234,729,470) # Randomly hovers over a random skill Mouse.moveTo(stats_window[0]+rsx,stats_window[1]+rsy) RandTime.randTime(1,0,0,2,9,9)
def click_camelot(clicks): time.sleep(4) cx, cy = autopy.mouse.get_pos() x1 = cx - 1 y1 = cy - 1 x2 = cx + 1 y2 = cy + 1 for c in range(clicks): x = random.randint(x1, x2) y = random.randint(y1, y2) RandTime.randTime(0, 0, 0, 0, 0, 1) autopy.mouse.toggle(True, 1) RandTime.randTime(0, 0, 0, 0, 0, 2) autopy.mouse.toggle(False, 1) if random.randint(0, 4) == 0: Mouse.moveTo(x, y) RandTime.randTime(0, 0, 3, 0, 3, 5) if not RS.antiban('magic'): time.sleep(1.5)
def click_camelot(clicks): time.sleep(4) cx, cy = autopy.mouse.get_pos() x1 = cx - 1 y1 = cy - 1 x2 = cx + 1 y2 = cy + 1 for c in range(clicks): x = random.randint(x1,x2) y = random.randint(y1,y2) RandTime.randTime(0,0,0,0,0,1) autopy.mouse.toggle(True,1) RandTime.randTime(0,0,0,0,0,2) autopy.mouse.toggle(False,1) if random.randint(0,4)==0: Mouse.moveTo(x,y) RandTime.randTime(0,0,3,0,3,5) if not RS.antiban('magic'): time.sleep(1.5)
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