Ejemplo n.º 1
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')
Ejemplo n.º 2
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
Ejemplo n.º 3
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)
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
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)
Ejemplo n.º 9
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
Ejemplo n.º 10
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')
Ejemplo n.º 11
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)
Ejemplo n.º 12
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
Ejemplo n.º 13
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')
Ejemplo n.º 14
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)
Ejemplo n.º 15
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)
Ejemplo n.º 16
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)
Ejemplo n.º 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)
Ejemplo n.º 18
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)
Ejemplo n.º 19
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')
Ejemplo n.º 20
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')
Ejemplo n.º 21
0
    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)
Ejemplo n.º 22
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)
Ejemplo n.º 23
0
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)
Ejemplo n.º 24
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
Ejemplo n.º 25
0
 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)
Ejemplo n.º 26
0
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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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!")
Ejemplo n.º 30
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
Ejemplo n.º 31
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
Ejemplo n.º 32
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)
Ejemplo n.º 33
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}")
Ejemplo n.º 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)
Ejemplo n.º 35
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)
Ejemplo n.º 36
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)
Ejemplo n.º 37
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)
Ejemplo n.º 38
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)
Ejemplo n.º 39
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
Ejemplo n.º 40
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
Ejemplo n.º 41
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)
Ejemplo n.º 42
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)
Ejemplo n.º 43
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
Ejemplo n.º 44
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
Ejemplo n.º 45
0
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
Ejemplo n.º 46
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
Ejemplo n.º 47
0
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
Ejemplo n.º 48
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
Ejemplo n.º 49
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
Ejemplo n.º 50
0
def log_in(user='******', passwd='nopass'):
    #sets default size if not already on default
    RS.setWindowSize()
    rsx, rsy = RS.position()
    #moves to Existing User button
    Mouse.moveClick(rsx + (random.randint(403, 530)),
                    rsy + (random.randint(302, 326)), 1)
    #Types user name
    Keyboard.type_this(user)
    #presses tab
    delay_mili = random.random()
    os.system('xdotool key --delay {0} Tab'.format(delay_mili))

    #Types password
    Keyboard.type_this(passwd)
    #Moves to login button and clicks it
    Mouse.moveClick(rsx + (random.randint(238, 365)),
                    rsy + (random.randint(329, 353)), 1)
    #Waits 4 secs after login in
    time.sleep(4)
    RandTime.randTime(0, 0, 0, 0, 0, 9)
    #moves to login box(red login button)
    x, y = log_in_box()
    Mouse.moveClick(x, y)
Ejemplo n.º 51
0
        print('done!')
        break
#
    if nats:
        spell('alch')
        nats -= 1
        RandTime.randTime(0, 1, 9, 0, 3, 9)
    if souls:
        spell('stun')
        souls -= 1
    if bodys and not souls:
        spell('curse')
        bodys -= 1
    if (counter %
        (random.choice([2, 3])) == 0 or counter == 0) and ((souls > 0) or
                                                           (bodys > 0)):
        print(counter, 'Finding Monk')
        x1, y1, x2, y2 = findMonk()
    if (souls > 0) or (bodys > 0):
        if not RS.is_button_selected('magic'):
            RS.press_button('magic')
        x, y = genCoords(x1, y1, x2, y2)
        Mouse.moveClick(x, y, 1)
        if random.randint(1, 100) == 0:
            RandTime.randTime(0, 0, 0, 9, 9, 9)
        else:
            RandTime.randTime(0, 0, 0, 1, 2, 3)

    counter += 1
    RS.antiban('magic')
Ejemplo n.º 52
0
def dropJug(x,y):
    Mouse.moveClick(x,y, 3)
    RS.findOptionClick(x,y,'drop')
Ejemplo n.º 53
0
def find_grimmy_herbs_in_inventory(herb_object):
    rs_bag, bagx, bagy = rs.get_bag('bag and its coords', 'hsv')
    # finds all grimmys first
    low, high = herb_object.herbdic['grimmy2']
    low = np.array(low)
    high = np.array(high)
    # applies mask based on above values
    mask = cv2.inRange(rs_bag, low, high)

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

    # contours of all grimys found
    contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL,
                                   cv2.CHAIN_APPROX_SIMPLE)

    # adds a white rectangle to all grimmys
    for con in contours:
        x, y, w, h = cv2.boundingRect(con)
        cv2.rectangle(mask, (x, y), (x + w, y + h), (255, 255, 255), -1)
    # goes through each item and clicks it
    contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL,
                                   cv2.CHAIN_APPROX_SIMPLE)

    items_coords = []
    row = []
    col = 0
    for con in contours[::-1]:
        M = cv2.moments(con)
        #print(M)
        # gets center of object
        x, y = int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"])
        # makes coords relative to the window
        x += bagx
        y += bagy
        # creates a list from -20 to 20
        pixels = [i for i in range(-10, 10)]
        # randomly adds value from pixels list
        x += random.choice(pixels)
        y += random.choice(pixels)

        row.append((x, y))

        col += 1
        # appends the row
        if col == 4:
            items_coords.append(row)
            row = []
            col = 0
    # makes sure to clean the last 3 herbs in bank
    if len(contours) <= 3:
        items_coords.append(row)

    # clicks on herbs in a zigzag pattern
    row = 2
    for rows in items_coords:
        # first row gets clicked from left to right
        if row % 2 == 0:
            for coords in rows:
                x, y = coords
                Mouse.moveClick(x, y, 1)  #right clicks on given x,y coords
                #rs.hc.move((x,y),.5)
                #rs.hc.click()
                randTime(0, 0, 0, 0, 0, 7)
                randTime(0, 0, 0, 0, 0, 5)
                randTime(0, 0, 1, 0, 0, 1)

            row += 1
            continue
        else:
            # inverts this row, from right to left
            for coords in rows[::-1]:
                x, y = coords
                Mouse.moveClick(x, y, 1)  #right clicks on given x,y coords
                #rs.hc.move((x,y),.5)
                #rs.hc.click()
                randTime(0, 0, 0, 0, 0, 7)
                randTime(0, 0, 0, 0, 0, 5)
                randTime(0, 0, 1, 0, 0, 1)
        row += 1
Ejemplo n.º 54
0
def find_grimmy_herbs_in_inventory(herb_object):
    rs_bag, bagx, bagy = RS.get_bag('bag and its coords', 'hsv')
    # finds all grimmys first
    low, high = herb_object.herbdic['grimmy2']
    low = np.array(low)
    high = np.array(high)
    # applies mask based on above values
    mask = cv2.inRange(rs_bag, low, high)

    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)

    # adds a white rectangle to all grimmys
    for con in contours:
        x, y, w, h = cv2.boundingRect(con)
        cv2.rectangle(mask,(x,y),(x+w,y+h),(255,255,255),-1)
    # goes through each item and clicks it
    _, contours, _ = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    items_coords = []
    row = []
    col = 0
    for con in contours[::-1]:
        M = cv2.moments(con)
        #print(M)
        # gets center of object
        x,y = int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"])
        # makes coords relative to the window
        x += RSX + bagx
        y += RSY + bagy 
        # creates a list from -20 to 20
        pixels = [i for i in range(-10,10)]
        # randomly adds value from pixels list
        x += random.choice(pixels)
        y += random.choice(pixels)

        row.append((x,y))

        col += 1
        # appends the row 
        if col == 4:
            items_coords.append(row)
            row = []
            col = 0
    # makes sure to clean the last 3 herbs in bank
    if len(contours) <= 3:
        items_coords.append(row)
    
    # clicks on herbs in a zigzag pattern
    row = 2
    for rows in items_coords:
        # first row gets clicked from left to right
        if row % 2 == 0:
            for coords in rows:
                x, y = coords
                Mouse.moveClick(x,y, 1)#right clicks on given x,y coords
                randTime(0,0,0,0,0,7)
                randTime(0,0,0,0,0,5)
                randTime(0,0,1,0,0,1)

            row += 1
            continue
        else:
        # inverts this row, from right to left
            for coords in rows[::-1]:
                x, y = coords
                Mouse.moveClick(x,y, 1)#right clicks on given x,y coords
                randTime(0,0,0,0,0,7)
                randTime(0,0,0,0,0,5)
                randTime(0,0,1,0,0,1)
        row += 1
Ejemplo n.º 55
0
high= np.array(dark_wizard[1])

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

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

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

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

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

areas = {}

for i,con in enumerate(contours):
    M = cv2.moments(con) 
    area =  cv2.contourArea(con)
    if area > 200:
        cx = int(M['m10']/M['m00'])
        cy = int(M['m01']/M['m00'])

        Mouse.moveClick(cx,cy,1)
        print(area)
        areas[i] = area
        break

#print(areas)
#cv2.imshow('img', mask)
#cv2.waitKey(0)
Ejemplo n.º 56
0
while True:
    if counter >= nats+souls+bodys:
        print('done!')
        break
#        
    if nats:
        spell('alch')
        nats -= 1
        RandTime.randTime(0,1,9,0,3,9)
    if souls:
        spell('stun')
        souls -= 1
    if bodys and not souls:
        spell('curse')
        bodys -= 1
    if (counter % (random.choice([2,3])) == 0 or counter == 0) and ((souls > 0) or (bodys > 0)):
        print(counter,'Finding Monk')
        x1,y1,x2,y2 = findMonk()
    if (souls > 0) or (bodys > 0): 
        if not RS.is_button_selected('magic'):
            RS.press_button('magic')
        x, y = genCoords(x1,y1,x2, y2)
        Mouse.moveClick(x,y,1)
        if random.randint(1,100) == 0:
            RandTime.randTime(0,0,0,9,9,9)
        else:
            RandTime.randTime(0,0,0,1,2,3)

    counter += 1 
    RS.antiban('magic')
Ejemplo n.º 57
0
def dobowstring(pt, w, h, bgx, bgy):
    rsx, rsy = RS.position()
    x, y = pt
    x +=   bgx 
    y +=  bgy   
    Mouse.moveClick(x,y, 1)