def alching(clicks): RS.press_button('magic') for c in range(clicks): # autopy.mouse.toggle(True,1) # RandTime.randTime(0,0,0,0,0,1) # autopy.mouse.toggle(False,1) # # RandTime.randTime(0,0,0,0,9,9) # # autopy.mouse.toggle(True,1) # RandTime.randTime(0,0,0,0,0,1) # autopy.mouse.toggle(False,1) # # #randomly moves mouse # x = random.randint(x1,x2) # y = random.randint(y1,y2) # print(x,y) # randomly moves to alch spell x, y = Mouse.genCoords(713, 345, 720, 352) Mouse.moveClick(x + RSX, y + RSY, 1) #RandTime.randTime(0,1,0,0,1,9) # randomly moves to alched item x, y = Mouse.genCoords(697, 348, 713, 364) Mouse.moveClick(x + RSX, y + RSY, 1) RandTime.randTime(1, 1, 0, 1, 9, 9) RS.antiban('magic')
def alching(clicks): RS.press_button('magic') for c in range(clicks): # autopy.mouse.toggle(True,1) # RandTime.randTime(0,0,0,0,0,1) # autopy.mouse.toggle(False,1) # # RandTime.randTime(0,0,0,0,9,9) # # autopy.mouse.toggle(True,1) # RandTime.randTime(0,0,0,0,0,1) # autopy.mouse.toggle(False,1) # # #randomly moves mouse # x = random.randint(x1,x2) # y = random.randint(y1,y2) # print(x,y) # randomly moves to alch spell x,y = Mouse.genCoords(713,345,720,352) Mouse.moveClick(x+RSX,y+RSY,1) #RandTime.randTime(0,1,0,0,1,9) # randomly moves to alched item x,y = Mouse.genCoords(697,348,713,364) Mouse.moveClick(x+RSX,y+RSY,1) RandTime.randTime(1,1,0,1,9,9) RS.antiban('magic')
def logout(self): # Door Button x,y = Mouse.genCoords(636,495,650,515) x += self.rsx y += self.rsy Mouse.moveClick(x,y,1) # Log out Button x,y = Mouse.genCoords(581,428,707,450) x += self.rsx y += self.rsy Mouse.moveClick(x,y,1)
def logout(): rsx,rsy = position() # Door Button x,y = Mouse.genCoords(636,495,650,515) x +=rsx y +=rsy Mouse.moveClick(x,y,1) # Log out Button x,y = Mouse.genCoords(581,428,707,450) x +=rsx y +=rsy Mouse.moveClick(x,y,1)
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 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 skillHover(self, 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) randS = RandTime.randTime(0,0,1,1,0,9) self.hc.move(x,y,randS)
def press_button(button, *args): """Presses button on random coordinates stored in the buttons dictionary. Returns button coords if 'coors' passed as argument""" buttons = { 'combat':0, 'stats':(570,197,586,214), 'quest':0, 'inventory':(631,194,658,221), 'equipment':(666,196,687,216), 'prayer':(700,198,720,214), 'magic':(733,195,751,214), 'clan':0, 'friend':0, 'enemy':0, 'logout':0, 'options':0, 'emotes':0, 'music':0, 'quick-prayer':0, 'run':0 } #unpacks the tuple x1,y1,x2,y2 = buttons[button] try : if args[0] == 'coords': return x1,y1,x2,y2 except: pass #generates random coords x,y = Mouse.genCoords(x1,y1,x2,y2) #moves to those coords Mouse.moveClick(x,y,1)
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 tp_duel_arena(): RS.press_button('equipment') # Teleports to Duel Arena # moves to the ring equpiment x,y = Mouse.genCoords(689,395,712,417) Mouse.moveClick(x,y,3) RS.findOptionClick(x,y,'duelArenaTeleport')
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 press_button(self, button, *args): """Presses button on random coordinates stored in the buttons dictionary. Returns button coords if 'coors' passed as argument""" buttons = { 'combat':0, 'stats':(570,197,586,214), 'quest':0, 'inventory':(631,194,658,221), 'equipment':(666,196,687,216), 'prayer':(700,198,720,214), 'magic':(733,195,751,214), 'clan':0, 'friend':0, 'enemy':0, 'logout':0, 'options':0, 'emotes':0, 'music':0, 'quick-prayer':0, 'run':0 } #unpacks the tuple x1,y1,x2,y2 = buttons[button] try : if args[0] == 'coords': return x1,y1,x2,y2 except: pass #generates random coords x,y = Mouse.genCoords(x1,y1,x2,y2) #moves to those coords Mouse.moveClick(x,y,1)
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 click_item(item): bag, bagx, bagy = RS.get_bag("bag x y") loc, w, h = Match.this(bag, item) for pt in zip(*loc[::-1]): x1 = pt[0] + bagx y1 = pt[1] + bagy x2 = x1 + w - ((w / 2) / 2) y2 = y1 + h - ((h / 2) / 2) # Moving first point inwards x1 += (w / 2) / 2 y1 += (h / 2) / 2 # Gen random coords within the bound x, y = Mouse.genCoords(x1, y1, x2, y2) Mouse.moveClick(x, y, 1) #RandTime.randTime(0,5,0,0,5,0) break
def click_item(item): bag, bagx,bagy = RS.get_bag("bag x y") loc, w, h = Match.this(bag, item) for pt in zip(*loc[::-1]): x1 = pt[0] + bagx y1 = pt[1] + bagy x2 = x1 + w - ((w/2)/2) y2 = y1 + h - ((h/2)/2) # Moving first point inwards x1 += (w/2) / 2 y1 += (h/2) / 2 # Gen random coords within the bound x,y = Mouse.genCoords(x1,y1,x2,y2) Mouse.moveClick(x,y,1) #RandTime.randTime(0,5,0,0,5,0) 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
def antiban(skill): rsx,rsy = position() rn =random.randint(0,99) if rn == 0: print("Starting antiban") # 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) #hovers over a certain skill skillHover(skill) moveback(skill) return True #returns true if antiban ran, to let me know if it acutally did ran elif rn == 1: print("Starting antiban") skillsHover(rsx,rsy) moveback(skill) return True
def antiban(self, skill): #rsx,rsy = position() rn =random.randint(0,99) if rn == 0: print("Starting antiban") # Tuples of locations stats_btn = Mouse.genCoords(567,194,589,215) #Clicks the skills button Mouse.moveClick(stats_btn[0]+self.rsx,stats_btn[1]+self.rsy,1) #hovers over a certain skill self.skillHover(skill) self.moveback(skill) return True #returns true if antiban ran, to let me know if it acutally did ran elif rn == 1: print("Starting antiban") self.skillsHover(self.rsx,self.rsy) self.moveback(skill) return True
def detect_fire_altar(): img = Screenshot.shoot(45,61,455,300, 'hsv') # lower and upper reddish colors for fire altar low = np.array([0,74,107]) high= np.array([13,110,137]) # Mask mask = cv2.inRange(img, low, high) #cv2.imshow('mask', mask) try: ############################################################ Morphological closing """Using it to remove noise pixels inside the found object""" # kernel is the structuring element which decides the nature of operation kernel = np.ones((5,5), np.uint8) # closing is the img w/ no noise closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel) #cv2.imshow('closing', closing) ################################################################ Gaussian blurr blur = cv2.GaussianBlur(closing, (5,5),0) #cv2.imshow('blur', blur) ################################################################# Contours # Find Contours """findContours fucntion modifies the source image. so if you want to source image even after finding contours, already store it to some other varialbe""" # source|cnt retrival mode |contour aprox method contours, _ = cv2.findContours(blur, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) #cnt = contours[1] #cv2.drawContours(img, contours, -1, (255,255,255), 1) ################################################################# Minimum enclosing circle #ellipse = cv2.fitEllipse(cnt) #cv2.ellipse(img_c, ellipse, (0,255,0),2) ################################################################# Rect around all contours all_xs = [] all_ys = [] # find max min x, y values of all contours for con in contours: for a in con: all_xs.append(a[0][0]) all_ys.append(a[0][1]) x1 = min(all_xs) y1 = min(all_ys) x2 = max(all_xs) y2 = max(all_ys) # Moving x in by half of half x1 += ((x2-x1)/2)/2 x2 -= ((x2-x1)/2)/2 # Moving Y in by half of half y1 += ((y2-y1)/2)/2 y2 -= ((y2-y1)/2)/2 # Adding Screenshot first point coords x1 += 45 x2 += 45 y1 += 61 y2 += 61 print(x1,y1,x2,y2) x, y = Mouse.genCoords(x1,y1,x2,y2) Mouse.moveClick(x,y,1) #print(x1,y1,x2,y2) # Drawing rect around the xs ys #cv2.rectangle(img, (x1,y1),(x2,y2),(255,255,255),1) #cv2.imshow('img', img) #cv2.waitKey(0) #cv2.destroyAllWindows() return True except: print("Not found!\nTrying Again\n") time.sleep(.5) return False
def tp_castle_wars(): RS.press_button('equipment') x,y = Mouse.genCoords(689,395,712,417) Mouse.moveClick(x,y,3) RS.findOptionClick(x,y,'castleWarsTeleport')