Exemple #1
0
    def findFishBubbles(self,click_n,func,*args):
        """Pass a function to do after it finds the fish bubbles"""

        # water bubbles
        #low = np.array([103,81,0])
        #high = np.array([111,255,255])
        play_screen = Screenshot.shoot(6,59,510,355,'hsv')

        low = np.array([220,50,100])
        high = np.array([255,255,255])
        mask = cv2.inRange(play_screen, low, high)

        #cv2.imshow('img', mask)
        #cv2.waitKey(0)

        kernel = np.ones((5,5), np.uint8)
        dilation = cv2.dilate(mask, kernel, iterations = 1)

        #cv2.imshow('dilation', dilation)
        #cv2.waitKey(0)

        _, contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        for c in random.choice(contours):
            (x, y, w, h) = cv2.boundingRect(c)
            x += 6 
            y += 59
            x2 = x + w 
            y2 = y + h 
            Mouse.randMove(x,y,x2,y2,click_n)
            # pass args to fucntion doing the actions
            # fucn should return true if needs to continue loking  at other bubbles
            if func():
                continue
            else:
                return
Exemple #2
0
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)
Exemple #3
0
    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)
Exemple #4
0
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)
Exemple #5
0
def find_ham_guard():
    import random
    try:
        ps, psx, psy = RS.getPlayingScreen()

        lower_pink = np.array([154,0,0])
        upper_pink = np.array([160,255,255])

        mask = cv2.inRange(ps, lower_pink, upper_pink)


        _, contours, _ = cv2.findContours(mask.copy(), 1,2)

        for cnt in contours:
            if cv2.contourArea(cnt) <= 1:
                continue
            #print("Area: {}".format(cv2.contourArea(cnt)))
            M = cv2.moments(cnt)
            cx = int(M['m10']/M['m00'])
            cy = int(M['m01']/M['m00'])

            cx += psx
            cy += psy

            cx += random.randint(-20,20)
            cy += random.randint(-20,20)

            # Find bouding box coords

            Mouse.moveClick(cx,cy, 3)
            break

        RS.findOptionClick(cx,cy, 'pickpocket')
    except Exception as e:
        print(e)
Exemple #6
0
    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)
Exemple #7
0
def find_prayer_pot():
    rs_bag, bagx, bagy = RS.get_bag('bag coords', 'hsv')
    # prayer potion color ranges
    low = np.array([78,140,0])
    high= np.array([81,225,211])
    mask = cv2.inRange(rs_bag, low, high)

    kernel = np.ones((5,5), np.uint8)
    dilation = cv2.dilate(mask, kernel, iterations = 1)
    
    _,contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    for con in contours:
        x, y, w, h = cv2.boundingRect(con)
        cv2.rectangle(mask,(x,y), (x+w, y+h), (255,255,255),-1)

    _,contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    for con in contours[::-1]:
        M = cv2.moments(con)
        mx, my = int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"])
        mx += RSX + bagx
        my += RSY + bagy

        mx += random.randint(-7,7)
        my += random.randint(-12,5)

        Mouse.moveClick(mx,my,1)
        #Mouse.moveTo(mx,my)
        break
Exemple #8
0
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')
Exemple #9
0
 def findCageOptionInBubbles(self):
     """Pass args from findFishBubbles meth. Finding cage option in fishing guild"""
     if self.findCageOption():
         Mouse.randMove(0,0,700,500, 1)
         return True
     else:
         return
Exemple #10
0
def withdrawFromBank(template_):
    rsx, rsy = RS.position()
    bankWindow, x1, y1 = RS.getBankWindow()
    loc, w, h = Match.this(bankWindow,template_)
    for pt in zip(*loc[::-1]):
        #unpackaged pt
        x, y = pt
        #make btm coords
        btmx = x + x1 + w - 5
        btmy = y + y1 + h - 5

        #add bankwindow+RS coords to pt
        x += x1 + 5
        y += y1 + 5
        #gen random coords
        x = random.randint(x,btmx)
        y = random.randint(y,btmy)

     
        Mouse.moveClick(x, y, 3 )
        #removing RS coords since they are added findOptionClick
        x -= rsx
        y -= rsy
        RS.findOptionClick(x,y,'withdraw14')
        break
Exemple #11
0
    def find_transportation_arrow(self):
        run = 1
        # moves to north east area of mini map
        Mouse.randMove(680-20,65-20,680+20,65+20,1)
        time.sleep(5)
        while run:
            mini_map = Screenshot.shoot(571,29,718,180,'hsv')
            low = np.array([10,101,147])
            high = np.array([13,255,211])

            # applies mask
            mask = cv2.inRange(mini_map, low, high)
            # removes any noise
            kernel = np.ones((5,5), np.uint8)
            dilation = cv2.dilate(mask, kernel, iterations = 1)

            _, contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
            for c in contours:
                (x, y, w, h) = cv2.boundingRect(c)
                x += 568
                y += 36
                x2 = x + w
                y2 = y + h 
                Mouse.randMove(x,y,x2,y2,1)
                run = 0
            time.sleep(1)
            print('running again')
Exemple #12
0
def find_ham_guard():
    import random
    try:
        ps, psx, psy = RS.getPlayingScreen()

        lower_pink = np.array([154, 0, 0])
        upper_pink = np.array([160, 255, 255])

        mask = cv2.inRange(ps, lower_pink, upper_pink)

        _, contours, _ = cv2.findContours(mask.copy(), 1, 2)

        for cnt in contours:
            if cv2.contourArea(cnt) <= 1:
                continue
            #print("Area: {}".format(cv2.contourArea(cnt)))
            M = cv2.moments(cnt)
            cx = int(M['m10'] / M['m00'])
            cy = int(M['m01'] / M['m00'])

            cx += psx
            cy += psy

            cx += random.randint(-20, 20)
            cy += random.randint(-20, 20)

            # Find bouding box coords

            Mouse.moveClick(cx, cy, 3)
            break

        RS.findOptionClick(cx, cy, 'pickpocket')
    except Exception as e:
        print(e)
Exemple #13
0
def find_template(template_file, option=None):#pass template to function
    #option == to option in menu when righ-clicked on item
    #checks to see wheater to add cur dir or not
    if "/" not in template_file:
        template_file = cwd+"/imgs/"+template_file

    rs_bag, bagx,bagy = RS.get_bag("bag, and it's coords") #Screenshot taken here, 
    #loc is where the templates found are in 
    loc, w, h = Match.this(rs_bag, template_file)
    #for loops iterates through every found template
    for pt in zip(*loc[::-1]):#goes through each found image
        #pt = ((pt[0]+bagx),(pt[1]+bagy))
        #pt is the Top-left coord of the found template


        #create Bott-Right coord of found template
        btmX = pt[0] + w - ((w/2)/2)
        btmY = pt[1] + h - ((h/2)/2)
        #moving the pt coord of the template a bit to the right, so options menu get brought up
        pt = (pt[0]+((w/2)/2), pt[1]+((h/2)/2))

        #gencoord adds RS position
        x, y = gen_coords(pt,btmX, btmY)#gets random x, y coords relative to RSposition on where to click
        #x, y = Mouse.randCoord(pt, w, h)
        if option == 'click' or option == 1:
            Mouse.moveClick(x,y, 1)#left clicks on given x,y coords
        else:
            Mouse.moveClick(x,y, 3)#right clicks on given x,y coords
            #menu_x, menu_y, menu = RS.getOptionsMenu(x,y)#takes screenshot of options menu and returns the point at Top-left of the menu
            RandTime.randTime(0,0,0,0,0,1)

            #RS.findOptionClick(x,y, menu_x, menu_y, menu, option)
            RS.findOptionClick(x,y,option)
        break
Exemple #14
0
def findWine():
    ######### find wine only in tabel!!! to make ti work better##########
    ps, psx, psy = RS.getPlayingScreen()

    lower = np.array([0,4,117])
    upper = np.array([16,22,182])

    mask = cv2.inRange(ps, lower, upper)

    # removes left side of stall
    w, h = mask.shape
    cv2.rectangle(mask,(0,0),(w,h),(0,0,0),-1)

    _, contours, _  = cv2.findContours(mask.copy(), 1, 2)
    # find biggest area
    biggest_area = 0
    for cnt in contours:
        if cv2.contourArea(cnt) > biggest_area:
            biggest_area = cv2.contourArea(cnt)

    # click on bnding rectangle of biggest area
    for cnt in contours:
        if cv2.contourArea(cnt) == biggest_area and biggest_area > 100:
            x,y,w,h = cv2.boundingRect(cnt)
            #cv2.rectangle(mask, (x,y), (x+w, y+h), (255,255,255), -1)
            x = x + psx
            y = y + psy

            Mouse.moveClick(x,y,1)
            return
Exemple #15
0
    def find_transportation_arrow(self):
        run = 1
        # moves to north east area of mini map
        Mouse.randMove(680 - 20, 65 - 20, 680 + 20, 65 + 20, 1)
        time.sleep(5)
        while run:
            mini_map = Screenshot.shoot(571, 29, 718, 180, 'hsv')
            low = np.array([10, 101, 147])
            high = np.array([13, 255, 211])

            # applies mask
            mask = cv2.inRange(mini_map, low, high)
            # removes any noise
            kernel = np.ones((5, 5), np.uint8)
            dilation = cv2.dilate(mask, kernel, iterations=1)

            _, contours, _ = cv2.findContours(dilation.copy(),
                                              cv2.RETR_EXTERNAL,
                                              cv2.CHAIN_APPROX_SIMPLE)
            for c in contours:
                (x, y, w, h) = cv2.boundingRect(c)
                x += 568
                y += 36
                x2 = x + w
                y2 = y + h
                Mouse.randMove(x, y, x2, y2, 1)
                run = 0
            time.sleep(1)
            print('running again')
Exemple #16
0
def closeBank():
    cwd = os.getcwd()
    rsx, rsy = position()
    x1 = rsx+449
    y1 = rsy+0
    x2 = rsx+522
    y2 = rsy+59

    closeButton = Screenshot.shoot(x1,y1,x2,y2)
    #SAVE FOR DEBUG
    #cv2.imwrite('debug_closeButton.png',closeButton)
    loc, w, h = Match.this(closeButton, cwd+'/imgs/bankXbutton.png')

    for pt in zip(*loc[::-1]):
        #making pt relative to the RS window
        pt = (pt[0] + x1, pt[1] + y1)
        #make Btm-Right pt
        btx = pt[0] + w
        bty = pt[1] + h
        #gen random coords
        rx = random.randint(pt[0], btx)
        ry = random.randint(pt[1], bty)
        #Move to and Click the X to close bank
        Mouse.moveClick(rx,ry,1)
        break
Exemple #17
0
def find_mine():
    global mine_this
    mines = {
        'tin1': ([0, 13, 104], [3, 73, 148]),
        'tin': ([0, 19, 121], [1, 30, 136]),
        'cooper': ([14, 135, 88], [15, 140, 169]),
        'iron': ([7, 138, 50], [10, 146, 85]),
        'gems': ([150, 223, 61], [151, 235, 169])
    }

    play_window, psx, psy = RS.getPlayingScreen()

    #mask = cv2.inRange(play_window, np.array(mines['tin'][0]), np.array(mines['tin'][1]))
    #mask = cv2.inRange(play_window, np.array(mines['cooper'][0]), np.array(mines['cooper'][1]))
    mask = cv2.inRange(play_window, np.array(mines[mine_this][0]),
                       np.array(mines[mine_this][1]))

    kernel = np.ones((20, 20), np.uint8)
    closing = cv2.morphologyEx(mask.copy(), cv2.MORPH_CLOSE, kernel)

    _, contours, _ = cv2.findContours(closing.copy(), 1, 2)
    # adds white rectangle around the mines
    for con in contours:
        x, y, w, h = cv2.boundingRect(con)
        cv2.rectangle(closing, (x, y), (x + w, y + h), (255, 255, 255), -1)
    #cv2.imshow('closing', closing)
    #cv2.waitKey(0)

    # finds mine mounts
    _, contours, _ = cv2.findContours(closing.copy(), 1, 2)
    mine_areas = {}
    for con in contours:
        #print("\n###############################")
        #print(cv2.contourArea(con))
        if cv2.contourArea(con) > 500:
            #print(cv2.contourArea(con))
            M = cv2.moments(con)
            cx = int(M['m10'] / M['m00'])
            cy = int(M['m01'] / M['m00'])
            # adds areas to dictionary to call next
            mine_areas[cv2.contourArea(con)] = (cx, cy)

    try:
        # gets random mine from mine areas
        random_mine = random.choice(mine_areas.keys())
    except Exception as e:
        #print(e)
        random_mine = mine_areas[mine_areas.keys()[0]]
    #print(random_mine)
    mine_center_x, mine_center_y = mine_areas[random_mine]
    # combine coords with playscreen to make relative
    mine_center_x += psx
    mine_center_y += psy

    # adds randomness to coords
    mine_center_x += random.randint(-11, 11)
    mine_center_y += random.randint(-11, 11)

    Mouse.moveClick(mine_center_x, mine_center_y, 1)
Exemple #18
0
def depositAll():
    rsx, rsy = position()

    x = rsx + random.randint(432,457)
    y = rsy + random.randint(320,348)

    Mouse.moveClick(x,y,1)
    RandTime.randTime(0,0,1,0,0,5)
Exemple #19
0
def find_mine():
    global mine_this
    mines = {
        'tin1':([0,13,104],[3,73,148]),
        'tin':([0,19,121],[1,30,136]),
        'cooper':([14,135,88],[15,140,169]),
        'iron':([7,138,50],[10,146,85]),
        'gems':([150,223,61],[151,235,169])
    }

    play_window,psx,psy = RS.getPlayingScreen()

    #mask = cv2.inRange(play_window, np.array(mines['tin'][0]), np.array(mines['tin'][1]))
    #mask = cv2.inRange(play_window, np.array(mines['cooper'][0]), np.array(mines['cooper'][1]))
    mask = cv2.inRange(play_window, np.array(mines[mine_this][0]), np.array(mines[mine_this][1]))

    kernel = np.ones((20,20), np.uint8)
    closing  =  cv2.morphologyEx(mask.copy(), cv2.MORPH_CLOSE, kernel)

    _,contours,_ = cv2.findContours(closing.copy(), 1, 2)
    # adds white rectangle around the mines
    for con in contours:
        x,y,w,h = cv2.boundingRect(con)
        cv2.rectangle(closing,(x,y),(x+w,y+h),(255,255,255),-1)
    #cv2.imshow('closing', closing)
    #cv2.waitKey(0)

    # finds mine mounts
    _,contours,_ = cv2.findContours(closing.copy(), 1, 2)
    mine_areas = {}
    for con in contours:
        #print("\n###############################")
        #print(cv2.contourArea(con))
        if cv2.contourArea(con) > 500:
            #print(cv2.contourArea(con))
            M = cv2.moments(con)
            cx = int(M['m10']/M['m00'])
            cy = int(M['m01']/M['m00'])
            # adds areas to dictionary to call next
            mine_areas[cv2.contourArea(con)] = (cx,cy)

    try:
        # gets random mine from mine areas
        random_mine = random.choice(mine_areas.keys())
    except Exception as e:
        #print(e)
        random_mine = mine_areas[mine_areas.keys()[0]]
    #print(random_mine)
    mine_center_x, mine_center_y = mine_areas[random_mine]
    # combine coords with playscreen to make relative
    mine_center_x += psx 
    mine_center_y += psy

    # adds randomness to coords
    mine_center_x += random.randint(-11,11)
    mine_center_y += random.randint(-11,11)

    Mouse.moveClick(mine_center_x, mine_center_y,1)
Exemple #20
0
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)
Exemple #21
0
def makeBow():
    """selects option to "make all" bows when bowstring and unstrung bow are clicked"""
    rsx, rsy = RS.position()
    x = random.randint(rsx+220, rsx+300)
    y = random.randint(rsy+408, rsy+467)
    Mouse.moveClick(x,y, 3)

    #Remvoing RS coords 
    x -= rsx
    y -= rsy
    RS.findOptionClick(x,y,'makeAll')
Exemple #22
0
    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
Exemple #23
0
def makeBow():
    """selects option to "make all" bows when bowstring and unstrung bow are clicked"""
    rsx, rsy = RS.position()
    x = random.randint(rsx + 220, rsx + 300)
    y = random.randint(rsy + 408, rsy + 467)
    Mouse.moveClick(x, y, 3)

    #Remvoing RS coords
    x -= rsx
    y -= rsy
    RS.findOptionClick(x, y, 'makeAll')
Exemple #24
0
 def doInMatched(self, *args, **kwargs):
     print("Found template")
     #unpacks args from Match.images
     img_pat,x,y,pt, w, h = args
     # combines pattern image w/ template coords
     x = pt[0]+x
     y = pt[1]+y
     # dimensions of pattern image
     img_pat_w, img_pat_h = img_pat.shape[::-1]
     # moves and clicks on the random passed coords
     Mouse.randMove(x,y,x+img_pat_w-10, y, 1)
Exemple #25
0
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)
Exemple #26
0
def find_motherload_mine():
    """Returns mine's location x, and y coords"""
    play_img, psx, psy = RS.getPlayingScreen()

    mines = {
        0: (np.array([0, 0, 153]), np.array([8, 25, 209])),
        1: (np.array([0, 0, 72]), np.array([2, 25, 144]))
    }

    for mine_key in mines.keys():
        #print("Mine: {}".format(mine_key))
        lower = mines[mine_key][0]
        upper = mines[mine_key][1]

        mask = cv2.inRange(play_img, lower, upper)

        kernel = np.ones((10, 10), np.uint8)

        closing = cv2.morphologyEx(mask.copy(), cv2.MORPH_CLOSE, kernel)

        #cv2.imshow('mask', mask)
        #cv2.imshow('closing', closing)
        #cv2.waitKey(0)

        _, contours, _ = cv2.findContours(mask.copy(), cv2.RETR_TREE,
                                          cv2.CHAIN_APPROX_SIMPLE)
        if contours[0].any():
            pass
        else:
            print('didnt find contours')
            break

        for con in contours[::-1]:
            M = cv2.moments(con)
            if cv2.contourArea(con) > 20:
                # Shows the mask

                #centroid from img moments
                cx = int(M['m10'] / M['m00'])
                cy = int(M['m01'] / M['m00'])

                #combine psx,psy coords with centroid coords from above
                cx += psx
                cy += psy

                #print("Area:",cv2.contourArea(con))
                #print(con[0][0][0],con[0][0][1])
                Mouse.moveClick(cx, cy, 1)
                return cx, cy
            else:
                continue
Exemple #27
0
def withdraw_from_bank(template_file, option):  #pass template to function
    #option == to option in menu options when righ-clicked on item
    #checks to see wheater to add cur dir or not
    cwd = os.getcwd()
    if "/" not in template_file:
        template_file = cwd + "/imgs/" + template_file
    #	print(template_file, "file in withraw_from_bank()")

    #creating bank window coords
    rsx, rsy = RS.position()
    #creates  sceenshot object of bankwindow,
    bankWindow, x1, y1 = RS.getBankWindow()
    #SAVE for DEBUG
    #cv2.imwrite('debug_inBankLog.png',bankWindow)

    # This For loop runs through found matches and clicks or right-clicks
    #loc == coordinates found in match
    loc, w, h = Match.this(bankWindow, template_file)
    for pt in zip(*loc[::-1]):  #goes through each found image
        #adds x1,y1 coords to pt to be relative to the window
        #pt = (x1+pt[0]+((w/2)/2), y1+pt[1]+((h/2)/2))#
        pt = (x1 + pt[0], y1 + pt[1])  #
        #Bottom-Right coords of found template
        btmX = pt[0] + w - ((w / 2) / 2)
        btmY = pt[1] + h - ((h / 2) / 2)

        # moving point inwards
        pt = (pt[0] + ((w / 2) / 2), pt[1] + ((h / 2) / 2))

        #create random coords within the coords of the found template
        rx = random.randint(pt[0], btmX)
        ry = random.randint(pt[1], btmY)

        if option == 'click':
            Mouse.moveClick(rx, ry, 1)
            break
        else:
            #right clicks on given x,y coords
            Mouse.moveClick(rx, ry, 3)
            RandTime.randTime(0, 0, 0, 0, 0, 1)

            #Removing rsx,rsy coords from rx, ry
            #becuase RS.getOptions adds them in by default
            rx -= rsx
            ry -= rsy

            RS.findOptionClick(rx, ry, 'withdrawAll')
            break
Exemple #28
0
def withdraw_from_bank(template_file, option):#pass template to function
    #option == to option in menu options when righ-clicked on item
    #checks to see wheater to add cur dir or not
    cwd = os.getcwd()
    if "/" not in template_file:
            template_file = cwd+"/imgs/"+template_file
    #	print(template_file, "file in withraw_from_bank()")

    #creating bank window coords
    rsx,rsy = RS.position()
    #creates  sceenshot object of bankwindow, 	
    bankWindow, x1, y1 = RS.getBankWindow()
    #SAVE for DEBUG
    #cv2.imwrite('debug_inBankLog.png',bankWindow)
    
    # This For loop runs through found matches and clicks or right-clicks
    #loc == coordinates found in match
    loc, w, h = Match.this(bankWindow, template_file)
    for pt in zip(*loc[::-1]):#goes through each found image
        #adds x1,y1 coords to pt to be relative to the window
        #pt = (x1+pt[0]+((w/2)/2), y1+pt[1]+((h/2)/2))#
        pt = (x1+pt[0], y1+pt[1])#
        #Bottom-Right coords of found template
        btmX =  pt[0] + w - ((w/2)/2)
        btmY =  pt[1] + h - ((h/2)/2)

        # moving point inwards
        pt = (pt[0]+((w/2)/2), pt[1]+((h/2)/2))

        #create random coords within the coords of the found template
        rx = random.randint(pt[0],btmX)
        ry = random.randint(pt[1],btmY)

        if option == 'click':
            Mouse.moveClick(rx,ry,1)
            break
        else:
            #right clicks on given x,y coords
            Mouse.moveClick(rx,ry, 3)
            RandTime.randTime(0,0,0,0,0,1)

            #Removing rsx,rsy coords from rx, ry 
            #becuase RS.getOptions adds them in by default
            rx -= rsx
            ry -= rsy

            RS.findOptionClick(rx,ry,'withdrawAll')
            break
Exemple #29
0
def open_cw_bank():
    """Finds the visiblest square of the chest in castle wars bank, wors better when viewing from above at shortest distance."""
    # gets RS window's position
    rsx,rsy = position()

    # Takes screenshot, as Hue-saturated-value image
    play_window,psx,psy = getPlayingScreen()

    psx += rsx
    psy += rsy



    lower_gray = np.array([0,15,55])
    upper_gray = np.array([10,25,125])

    # Makes a black/white mask
    mask = cv2.inRange(play_window, lower_gray, upper_gray)
    # inverts selection
    #res = cv2.bitwise_and(play_window, play_window, mask=mask)
    kernel = np.ones((5,5), np.uint8)
    dilation = cv2.dilate(mask, kernel, iterations = 1)

    #cv2.imshow('img', dilation)
    #cv2.waitKey(0)

    # Finds contours
    _,contours,_ = cv2.findContours(dilation.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

    try:
        # looks for center of grey color with biggest area, > 3000
        for con in contours:
            if cv2.contourArea(con) > 3000:
                M = cv2.moments(con)
                # finds centroid
                cx,cy = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                psx += cx
                psy += cy
                # adds randomness to coords
                psx += random.randint(-17,17)
                psy += random.randint(-17,17)

                #move click chest
                Mouse.moveClick(psx,psy,1)
                RandTime.randTime(0,0,0,0,9,9)
                break
    except Exception as e:
        print("Bank NOT found!\nMove camera around!")
Exemple #30
0
def check_mine_availability(mine_x, mine_y):
    RandTime.randTime(3, 0, 0, 5, 9, 9)
    cmx, cmy = Mouse.mouse_loc()
    mine_x = cmx - mine_x
    mine_y = cmy - mine_y
    while 1:
        # expands by 4X4 to check color values
        x = mine_x - 2
        y = mine_y - 2
        x2 = mine_x + 2
        y2 = mine_y + 2

        checked_area = Screenshot.shoot(x, y, x2, y2, 'hsv')

        lower_gray = np.array([0, 0, 153])
        upper_gray = np.array([8, 25, 209])

        mask = cv2.inRange(checked_area, lower_gray, upper_gray)
        for colors in mask:
            for value in colors:
                if value == 255:
                    print('mine ACTIVE')
                    RandTime.randTime(5, 0, 0, 5, 9, 9)
                    break
        else:
            print("mine INACTIVE")
            break
Exemple #31
0
    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)
Exemple #32
0
def find_bank_booth():
    """Finds bank booth and clicks it.  Returns True if found, else False"""

    bank_booth_glass_window = ([0,72,149],[179,82,163])
    # take screenshot of playing area
    play_area_screen,psx,psy = getPlayingScreen()

    # find glasswindow for bankbooth
    mask = cv2.inRange(play_area_screen, np.array(bank_booth_glass_window[0]), np.array(bank_booth_glass_window[1]))

    # gets RS window's position
    rsx,rsy = position()

    psx += rsx
    psy += rsy

    kernel = np.ones((3,3), np.uint8)
    closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)


    #cv2.imshow('img', closing)
    #cv2.waitKey(0)

    # Finds contours
    _,contours,_ = cv2.findContours(closing.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

    try:
        for con in contours:
            if cv2.contourArea(con) > 10:
                #print(cv2.contourArea(con))
                M = cv2.moments(con)
                # finds centroid
                cx,cy = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                psx += cx
                psy += cy
                # adds randomness to coords
                psx += random.randint(-7,7)
                psy += random.randint(-7,7)

                #move click
                Mouse.moveClick(psx,psy,1)
                RandTime.randTime(0,0,0,0,9,9)
                return 1
    except Exception as e:
        print("Bank NOT found!\nMove camera around!")
    # returns False if bank not found
    return 0
Exemple #33
0
    def find_bank_booth(self):
        """Finds bank booth and clicks it.  Returns True if found, else False"""

        bank_booth_glass_window = ([0,72,149],[179,82,163])
        # take screenshot of playing area
        play_area_screen,psx,psy = self.getPlayingScreen()

        # find glasswindow for bankbooth
        mask = cv2.inRange(play_area_screen, np.array(bank_booth_glass_window[0]), np.array(bank_booth_glass_window[1]))

        # gets RS window's position
        #rsx,rsy = position()

        psx += self.rsx
        psy += self.rsy

        kernel = np.ones((3,3), np.uint8)
        closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)


        #cv2.imshow('img', closing)
        #cv2.waitKey(0)

        # Finds contours
        _,contours,_ = cv2.findContours(closing.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

        try:
            for con in contours:
                if cv2.contourArea(con) > 10:
                    #print(cv2.contourArea(con))
                    M = cv2.moments(con)
                    # finds centroid
                    cx,cy = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                    psx += cx
                    psy += cy
                    # adds randomness to coords
                    psx += random.randint(-7,7)
                    psy += random.randint(-7,7)

                    #move click
                    Mouse.moveClick(psx,psy,1)
                    RandTime.randTime(0,0,0,0,9,9)
                    return 1
        except Exception as e:
            print(f"Bank NOT found!\nMove camera around!\n{e}")
        # returns False if bank not found
        return 0
Exemple #34
0
def splasher():
    time.sleep(3)
    print('starting')
    cx, cy = autopy.mouse.get_pos()
    print('grabbed position')
    x1 = cx - 5
    y1 = cy - 5
    x2 = cx + 5
    y2 = cy + 5
    while True:
        x = random.randint(x1, x2)
        y = random.randint(y1, y2)
        Mouse.moveClick(x, y, 1)
        multiplier = random.randint(1, 5)
        print("waiting for {}".format((60 * multiplier) // 60))
        time.sleep(60 * multiplier)
        RandTime.randTime(0, 0, 0, 0, 0, 9)
Exemple #35
0
def splasher():
    time.sleep(3)
    print('starting')
    cx, cy = autopy.mouse.get_pos()
    print('grabbed position')
    x1 = cx - 5
    y1 = cy - 5
    x2 = cx + 5
    y2 = cy + 5
    while True:
        x = random.randint(x1, x2)
        y = random.randint(y1, y2)
        Mouse.moveClick(x,y,1)
        multiplier = random.randint(1,5)
        print("waiting for {}".format((60*multiplier)//60))
        time.sleep(60*multiplier)
        RandTime.randTime(0,0,0,0,0,9)
Exemple #36
0
    def open_cw_bank(self):
        """Finds the visiblest square of the chest in castle wars bank, wors better when viewing from above at shortest distance."""

        # Takes screenshot, as Hue-saturated-value image
        play_window,psx,psy = self.getPlayingScreen('hsv')
        lower_gray = np.array([0,15,55])
        upper_gray = np.array([10,25,125])

        # Makes a black/white mask
        mask = cv2.inRange(play_window, lower_gray, upper_gray)
        # inverts selection
        #res = cv2.bitwise_and(play_window, play_window, mask=mask)
        kernel = np.ones((5,5), np.uint8)
        dilation = cv2.dilate(mask, kernel, iterations = 1)

        #cv2.imshow('img', dilation)
        #cv2.waitKey(2000)
        #cv2.destroyAllWindows()

        # Finds contours
        contours,_ = cv2.findContours(dilation.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

        try:
            # looks for center of grey color with biggest area, > 3000
            for con in contours:
                #print(cv2.contourArea(con))
                if cv2.contourArea(con) > 3000:
                    #print(f"big area found {cv2.contourArea(con)}")

                    M = cv2.moments(con)
                    # finds centroid
                    cx,cy = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                    psx += cx
                    psy += cy
                    # adds randomness to coords
                    psx += random.randint(-17,17)
                    psy += random.randint(-17,17)

                    #move click chest
                    Mouse.moveClick(psx,psy,1)
                    #pyclick.HumanClicker.move((psx, psy), 1)
                    #pyclick.HumanClicker.click()
                    RandTime.randTime(1,0,0,2,9,9)
                    break
        except Exception as e:
            print(f"Bank NOT found!\nMove camera around!\n{e}")
Exemple #37
0
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
Exemple #38
0
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
Exemple #39
0
def keep_clicking():
    time.sleep(3)
    cx, cy  = autopy.mouse.get_pos()
    x1 = cx - 2
    y1 = cy - 2
    x2 = cx + 2
    y2 = cy + 2
    counts = 0
    while counts < 30:
        if count_logs('/home/jj/github/osrmacro/imgs/mapleLog.png') == 0:
            x = random.randint(x1,x2)
            y = random.randint(y1,y2)
            Mouse.moveClick(x,y,1)
            timer += 1
            RandTime.randTime(0,0,1,0,9,9)
            time.sleep(7)
        time.sleep(10)
        RandTime.randTime(0,0,1,0,9,9)
Exemple #40
0
def spell(*args, **kwargs):
    for s in args:
        if s == 'curse':
            x, y = genCoords(664 + rsx, 272 + rsy, 672 + rsx, 280 + rsy)
            Mouse.moveClick(x, y, 1)
        elif s == 'alch':
            x, y = genCoords(710 + rsx, 346 + rsy, 720 + rsx, 356 + rsy)
            Mouse.moveClick(x, y, 1)
            RandTime.randTime(0, 1, 0, 0, 1, 9)
            x, y = genCoords(700 + rsx, 353 + rsy, 714 + rsx, 364 + rsy)
            Mouse.moveClick(x, y, 1)
            RandTime.randTime(0, 1, 0, 1, 9, 9)
        elif s == 'stun':
            x, y = genCoords(618 + rsx, 443 + rsy, 621 + rsx, 447 + rsy)
            Mouse.moveClick(x, y, 1)
        elif s == 'enfeeble':
            x, y = genCoords(686 + rsx, 416 + rsy, 696 + rsx, 426 + rsy)
            Mouse.moveClick(x, y, 1)
Exemple #41
0
def keep_clicking():
    time.sleep(3)
    cx, cy = autopy.mouse.get_pos()
    x1 = cx - 2
    y1 = cy - 2
    x2 = cx + 2
    y2 = cy + 2
    counts = 0
    while counts < 30:
        if count_logs('/home/jj/github/osrmacro/imgs/mapleLog.png') == 0:
            x = random.randint(x1, x2)
            y = random.randint(y1, y2)
            Mouse.moveClick(x, y, 1)
            timer += 1
            RandTime.randTime(0, 0, 1, 0, 9, 9)
            time.sleep(7)
        time.sleep(10)
        RandTime.randTime(0, 0, 1, 0, 9, 9)
Exemple #42
0
    def findFishingIcon(self):
        #fish color
        low = np.array([93,119,84])
        high = np.array([121,255,255])
        mask, mm_x, mm_y = self.mini_map_mask(low, high)

        _, contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        for c in contours:
            (x, y, w, h) = cv2.boundingRect(c)
            x += mm_x 
            y += mm_y
            x2 = x + w 
            y2 = y + h 
            Mouse.randMove(x,y,x2,y2,1)
            run= 0 
            time.sleep(1)
            return 0
        return 1
Exemple #43
0
def spell(*args, **kwargs):
    for s in args:
        if s == 'curse':
            x, y = genCoords(664+rsx,272+rsy,672+rsx,280+rsy)
            Mouse.moveClick(x,y, 1)
        elif s == 'alch':
            x, y = genCoords(710+rsx,346+rsy,720+rsx,356+rsy)
            Mouse.moveClick(x,y, 1)
            RandTime.randTime(0,1,0,0,1,9)
            x, y = genCoords(700+rsx,353+rsy,714+rsx,364+rsy)
            Mouse.moveClick(x,y, 1)
            RandTime.randTime(0,1,0,1,9,9)
        elif s == 'stun':
            x, y = genCoords(618+rsx,443+rsy,621+rsx,447+rsy)
            Mouse.moveClick(x,y,1)
        elif s == 'enfeeble':
            x, y = genCoords(686+rsx,416+rsy,696+rsx,426+rsy)
            Mouse.moveClick(x,y,1)
Exemple #44
0
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
Exemple #45
0
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
Exemple #46
0
    def findBankIcon(self):
        # bank colo
        low = np.array([26,160,176])
        high = np.array([27,244,228])
        mask, mm_x, mm_y = self.mini_map_mask(low, high)

        cv2.imshow('mask', mask)
        cv2.waitKey(0)

        _, contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

        for c in contours:
            (x, y, w, h) = cv2.boundingRect(c)
            x += 568 
            y += 36
            x2 = x + w 
            y2 = y + h 
            Mouse.randMove(x,y,x2,y2,1)
            run= 0 
            time.sleep(1)
            return
Exemple #47
0
def custom_clicker(wait_in_secs, count_to, click, range_sq):
    print("move mouse to location to autoclick")
    time.sleep(3)
    cx, cy = autopy.mouse.get_pos()
    print("Got {} {}".format(cx, cy))
    x1 = cx - range_sq
    y1 = cy - range_sq
    x2 = cx + range_sq
    y2 = cy + range_sq

    counter = 0

    while counter < count_to:
        x = random.randint(x1, x2)
        y = random.randint(y1, y2)
        Mouse.moveClick(x, y, click)
        counter += 1
        # randomize range of time to wait
        #custom_clicker(wait_in_secs, count_to, click , range_sq ):
        print("Randomizing time")
        RandTime.randTime(2, 0, 0, wait_in_secs, 9, 9)
Exemple #48
0
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')
Exemple #49
0
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')
Exemple #50
0
def clicker(item):
    time.sleep(3)
    cx, cy  = autopy.mouse.get_pos()
    x1 = cx - 3
    y1 = cy - 3
    x2 = cx + 3
    y2 = cy + 3
    timer = 0
    if item == 'stringer':
        while timer < 30:
            x = random.randint(x1,x2)
            y = random.randint(y1,y2)
            Mouse.moveClick(x,y,1)
            timer +=1
            time.sleep(33)
            RandTime.randTime(0,0,1,0,0,9)
    else:
        while timer < 375:
            x = random.randint(x1,x2)
            y = random.randint(y1,y2)
            Mouse.moveClick(x,y,1)
            timer +=1
Exemple #51
0
def custom_clicker(wait_in_secs, count_to, click , range_sq ):
    print("move mouse to location to autoclick")
    time.sleep(3)
    cx, cy  = autopy.mouse.get_pos()
    print("Got {} {}".format(cx,cy))
    x1 = cx - range_sq
    y1 = cy -range_sq
    x2 = cx + range_sq
    y2 = cy + range_sq

    counter = 0


    while counter < count_to:
        x = random.randint(x1,x2)
        y = random.randint(y1,y2)
        Mouse.moveClick(x,y,click)
        counter += 1
        # randomize range of time to wait
#custom_clicker(wait_in_secs, count_to, click , range_sq ):
        print("Randomizing time")
        RandTime.randTime(2,0,0,wait_in_secs,9,9)
Exemple #52
0
    def find_fairy_ring(self):
        run = 1
        while run:
            play_screen = Screenshot.shoot(6, 59, 510, 355, 'hsv')
            # finding white on fairy ring inner circle
            low = np.array([107, 92, 93])
            high = np.array([113, 255, 129])

            mask = cv2.inRange(play_screen, low, high)

            kernel = np.ones((10, 10), np.uint8)
            dilation = cv2.dilate(mask, kernel, iterations=1)
            #closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel)

            #_,contours,_ = cv2,findContours(closing.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
            _, contours, _ = cv2.findContours(dilation, cv2.RETR_TREE,
                                              cv2.CHAIN_APPROX_SIMPLE)

            for con in contours:
                print("Area: {}".format(cv2.contourArea(con)))
                if cv2.contourArea(con) > 1.0:
                    (x, y, w, h) = cv2.boundingRect(con)
                    x += self.rs_x
                    y += self.rs_y
                    x1 = x
                    y1 = y
                    x2 = x + w
                    y2 = y + h
                    print("x1:{} y1:{} x2:{} y2:{}".format(x1, y1, x2, y2))
                    #print(cv2.contourArea(con))
                    #M = cv2.moments(con)
                    # finds centroid
                    #x,y = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
                    Mouse.randMove(x1, y1, x2, y2, 3)
                    time.sleep(5)
                    if RS.findOptionClick(x1, y1, 'cis'):
                        run = 0
                    time.sleep(2)
                    break
Exemple #53
0
def clicker(item):
    time.sleep(3)
    cx, cy = autopy.mouse.get_pos()
    x1 = cx - 3
    y1 = cy - 3
    x2 = cx + 3
    y2 = cy + 3
    timer = 0
    if item == 'stringer':
        while timer < 30:
            x = random.randint(x1, x2)
            y = random.randint(y1, y2)
            Mouse.moveClick(x, y, 1)
            timer += 1
            time.sleep(33)
            RandTime.randTime(0, 0, 1, 0, 0, 9)
    else:
        while timer < 375:
            x = random.randint(x1, x2)
            y = random.randint(y1, y2)
            Mouse.moveClick(x, y, 1)
            timer += 1
Exemple #54
0
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)
Exemple #55
0
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)
Exemple #56
0
def withdrawFromBank(template_):
    rsx, rsy = RS.position()
    bankWindow, x1, y1 = RS.getBankWindow()
    loc, w, h = Match.this(bankWindow, template_)
    for pt in zip(*loc[::-1]):
        #unpackaged pt
        x, y = pt
        #make btm coords
        btmx = x + x1 + w - 5
        btmy = y + y1 + h - 5

        #add bankwindow+RS coords to pt
        x += x1 + 5
        y += y1 + 5
        #gen random coords
        x = random.randint(x, btmx)
        y = random.randint(y, btmy)

        Mouse.moveClick(x, y, 3)
        #removing RS coords since they are added findOptionClick
        x -= rsx
        y -= rsy
        RS.findOptionClick(x, y, 'withdraw14')
        break
Exemple #57
0
    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
Exemple #58
0
def find_template(template_file, option=None):  #pass template to function
    #option == to option in menu when righ-clicked on item
    #checks to see wheater to add cur dir or not
    if "/" not in template_file:
        template_file = cwd + "/imgs/" + template_file

    rs_bag, bagx, bagy = RS.get_bag(
        "bag, and it's coords")  #Screenshot taken here,
    #loc is where the templates found are in
    loc, w, h = Match.this(rs_bag, template_file)
    #for loops iterates through every found template
    for pt in zip(*loc[::-1]):  #goes through each found image
        #pt = ((pt[0]+bagx),(pt[1]+bagy))
        #pt is the Top-left coord of the found template

        #create Bott-Right coord of found template
        btmX = pt[0] + w - ((w / 2) / 2)
        btmY = pt[1] + h - ((h / 2) / 2)
        #moving the pt coord of the template a bit to the right, so options menu get brought up
        pt = (pt[0] + ((w / 2) / 2), pt[1] + ((h / 2) / 2))

        #gencoord adds RS position
        x, y = gen_coords(
            pt, btmX, btmY
        )  #gets random x, y coords relative to RSposition on where to click
        #x, y = Mouse.randCoord(pt, w, h)
        if option == 'click' or option == 1:
            Mouse.moveClick(x, y, 1)  #left clicks on given x,y coords
        else:
            Mouse.moveClick(x, y, 3)  #right clicks on given x,y coords
            #menu_x, menu_y, menu = RS.getOptionsMenu(x,y)#takes screenshot of options menu and returns the point at Top-left of the menu
            RandTime.randTime(0, 0, 0, 0, 0, 1)

            #RS.findOptionClick(x,y, menu_x, menu_y, menu, option)
            RS.findOptionClick(x, y, option)
        break