Exemplo n.º 1
0
def find_mining_icon(offset=0,*args):
    """needs work, not fucntional, copy pasted from findBankIcon"""
    # bank hue range
    low = np.array([26,160,176])
    high = np.array([27,244,228])
    mask, mm_x, mm_y = get_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)
        if args[0] == "n":
            x += mm_x
            y += mm_y - offset
            x2 = x + w
            y2 = y + (h/2) 
            Mouse.randMove(x,y,x2,y2,1)
            #Mouse.moveTo(x,y)
            RandTime.randTime(1,0,0,1,9,9)
            return

        x += mm_x
        y += mm_y
        x2 = x + w
        y2 = y + h
        Mouse.randMove(x,y,x2,y2,1)
        RandTime.randTime(1,0,0,1,9,9)
        return
Exemplo n.º 2
0
    def setPrice(self, price):

        # found = [self.self_window_coord[0],self.self_window_coord[1],self.self_window_coord[2],self.self_window_coord[3]]
        # found = [374,200,374,200]
        found = [
            356, 181, 356 + GC.offer_button_dimensions[0],
            181 + GC.offer_button_dimensions[1]
        ]

        found_coord = [
            self.self_window_coord[0] + found[0],
            self.self_window_coord[1] + found[1],
            self.self_window_coord[0] + found[2],
            self.self_window_coord[1] + found[3]
        ]

        # crop = Screenshot.crop(self.global_rs_image, found_coord)
        # cv2.imwrite(r'C:\Users\PPC\git\RS_BOT_2.0\aaaaacrop.png', crop)

        # found_coord = [found[0]+self.self_window_coord[0], found[1]+self.self_window_coord[1], found[0]+self.self_window_coord[0] + GC.offer_button_dimensions[0],
        #                found[1]+self.self_window_coord[1] + GC.offer_button_dimensions[1]]

        Mouse.clickRadius(
            self._calculateGlobalCoord(self.global_rs_coord, found_coord))
        # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord))
        # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord))

        RandTime.randTime(0, 0, 0, 2, 0, 0)
        Keyboard.type_this(price)
        Keyboard.press("enter")
Exemplo n.º 3
0
def right_click():
    #autopy.mouse.click()
    # pyautogui.moveTo(100, 200)
    pyautogui.mouseDown(button='right')
    RandTime.randomTime(2, 7)
    # RandTime.randTime(0, 0, 0, 0, 0, 1)  # time between click
    pyautogui.mouseUp(button='right')
Exemplo n.º 4
0
def findBankIcon(offset=0, *args):
    # bank hue range
    low = np.array([21,157,173])
    high = np.array([25,178,221])
    mask, mm_x, mm_y = get_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)
        try:
            if args[0] == "n":
                x += mm_x
                y += mm_y - offset
                x2 = x + w
                y2 = y + (h/2) 
                Mouse.randMove(x,y,x2,y2,1)
                #Mouse.moveTo(x,y)
                RandTime.randTime(1,0,0,1,9,9)
                return
        except:
            pass

        x += mm_x
        y += mm_y
        x2 = x + w
        y2 = y + h
        Mouse.randMove(x,y,x2,y2,1)
        RandTime.randTime(1,0,0,1,9,9)
        return
Exemplo n.º 5
0
def win32Click(x, y):
    print x, y
    win32api.SetCursorPos((x, y))
    RandTime.randTime(0, 0, 0, 0, 0, 28)  # time between click
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
    RandTime.randTime(0, 0, 0, 0, 0, 28)  # time between click
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
Exemplo n.º 6
0
def click():
    #autopy.mouse.click()
    # pyautogui.moveTo(100, 200)
    pyautogui.mouseDown(button='left')
    RandTime.randTime(0, 1, 0, 0, 2, 9)  #time between click
    # RandTime.randTime(0, 0, 0, 0, 0, 1)  # time between click
    pyautogui.mouseUp(button='left')
Exemplo n.º 7
0
def type_this(strings):
    """Types the passed characters with random pauses in between strokes"""
    for s in strings:
        # delay between key presses--key UP/DOWN
        #autopy.key.toggle(s, True)
        pyautogui.keyDown(s)
        RandTime.randomTime(2, 7)
        pyautogui.keyUp(s)
Exemplo n.º 8
0
def win32ClickRadius(coord):
    x = random.randint(coord[0], coord[2])
    y = random.randint(coord[1], coord[3])
    # print coord
    # print x,y
    win32api.SetCursorPos((x, y))
    RandTime.randTime(0, 0, 0, 0, 0, 28)  # time between click
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
    RandTime.randTime(0, 0, 0, 0, 0, 28)  # time between click
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
Exemplo n.º 9
0
def detect_money(top_left_corner, bottom_right_corner):
    RSTools.wait_for_w_coord(os.path.join(GC.anchor_path, "main_ge_anchor.png"), top_left_corner,bottom_right_corner)
    coords_of_item = (
        top_left_corner[0] + 690, top_left_corner[1] + 433, 20, 15)

    Mouse.move_to_radius(coords_of_item)
    Mouse.right_click()

    image = os.path.join(GC.anchor_path, "examine_coins.png")
    image_loc = pyautogui.locateOnScreen(image, region=(top_left_corner[0], top_left_corner[1], bottom_right_corner[0]-top_left_corner[0], bottom_right_corner[1]-top_left_corner[1]))
    while(image_loc == None):
        image_loc = pyautogui.locateOnScreen(image, region=(top_left_corner[0], top_left_corner[1], bottom_right_corner[0]-top_left_corner[0], bottom_right_corner[1]-top_left_corner[1]))
    print image_loc
    Mouse.click_radius(image_loc)
    RandTime.randomTime(1000, 1500)
    money_val = check_total_coins(top_left_corner, bottom_right_corner)
    print "Wallet", money_val
    return(money_val)
Exemplo n.º 10
0
def findFishingIcon():
    #fish color
    low = np.array([93,119,84])
    high = np.array([121,255,255])
    mask, mm_x, mm_y = get_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
        RandTime.randTime(1,0,0,1,9,9)
        return 0
    return 1
Exemplo n.º 11
0
    def decreasePrice(self, num_clicks):

        template = GC.offer_decrease

        found = Match.this(self.global_rs_image, template)
        # print found, "found"
        if found:
            found_coord = [
                found[0], found[1], found[0] + GC.offer_button_dimensions[0],
                found[1] + GC.offer_button_dimensions[1]
            ]

            for x in range(num_clicks):
                Mouse.clickRadius(
                    self._calculateGlobalCoord(self.global_rs_coord,
                                               found_coord))
                # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord))
                # Mouse.win32MoveToRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord))
                RandTime.randTime(0, 0, 0, 0, 0, 1)
Exemplo n.º 12
0
def find_furnance(offset=0,*args):
    """finds the inner orange in furnance icon on minimap"""
    # furnance hue range
    low = np.array([10,211,244])
    high = np.array([23,229,255])
    mask, mm_x, mm_y = get_mini_map_mask(low, high)


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

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

    _, contours, _ = cv2.findContours(dilation.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

    for c in contours:
        (x, y, w, h) = cv2.boundingRect(c)
        try:
            # clicks north of the icon
            if args[0] == "n":
                x += mm_x
                y += mm_y - offset
                x2 = x + w
                y2 = y + (h/2) 
                Mouse.randMove(x,y,x2,y2,1)
                #Mouse.moveTo(x,y)
                RandTime.randTime(1,0,0,1,9,9)
                return
        except:
            pass

        x += mm_x
        y += mm_y
        x2 = x + w
        y2 = y + h
        Mouse.randMove(x,y,x2,y2,1)
        RandTime.randTime(1,0,0,1,9,9)
        return
Exemplo n.º 13
0
def press(button):
    if button == 'enter':
        # autopy.key.toggle(autopy.key.K_RETURN, True)
        pyautogui.keyDown('enter')
        RandTime.randTime(0, 0, 1, 0, 0, 1)
        # autopy.key.toggle(autopy.key.K_RETURN, False)
        pyautogui.keyUp('enter')
    elif button == 'f5' or button == 'spec':
        pyautogui.keyDown('f5')
        RandTime.randTime(0, 0, 1, 0, 0, 1)
        pyautogui.keyUp('f5')
    elif button == 'f1' or button == 'inventory':
        pyautogui.keyDown('f1')
        RandTime.randTime(0, 0, 1, 0, 0, 1)
        pyautogui.keyUp('f1')
    elif button == 'f3' or button == 'prayer':
        pyautogui.keyDown('f3')
        RandTime.randTime(0, 0, 1, 0, 0, 1)
        pyautogui.keyUp('f3')
    elif button == 'f4' or button == 'magic':
        pyautogui.keyDown('f4')
        RandTime.randTime(0, 0, 1, 0, 0, 1)
        pyautogui.keyUp('f4')
Exemplo n.º 14
0
    def setQuantity(self, quantity):

        # found = [217,200,217,200]
        found = [
            199, 181, 199 + GC.offer_button_dimensions[0],
            181 + GC.offer_button_dimensions[1]
        ]

        found_coord = [
            self.self_window_coord[0] + found[0],
            self.self_window_coord[1] + found[1],
            self.self_window_coord[0] + found[2],
            self.self_window_coord[1] + found[3]
        ]
        # crop = Screenshot.crop(self.global_rs_image, found_coord)
        # cv2.imwrite(r'C:\Users\PPC\git\RS_BOT_2.0\aaaaacrop.png', crop)
        Mouse.clickRadius(
            self._calculateGlobalCoord(self.global_rs_coord, found_coord))
        # Mouse.win32ClickRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord))
        # Mouse.win32MoveToRadius(self._calculateGlobalCoord(self.global_rs_coord, found_coord))

        RandTime.randTime(0, 0, 0, 2, 0, 0)
        Keyboard.type_this(quantity)
        Keyboard.press("enter")
Exemplo n.º 15
0
def hold_key(key):
    pyautogui.keyDown(key)
    RandTime.randomTime(650, 750)
    # RandTime.randomTime(0, 5)
    pyautogui.keyUp(key)
    print "done"
Exemplo n.º 16
0
def press(button):
    if button == 'enter':
        pyautogui.keyDown('enter')
        RandTime.randomTime(2, 7)
        pyautogui.keyUp('enter')
    elif button == 'f1' or button == 'spec':
        pyautogui.keyDown('f1')
        RandTime.randomTime(2, 7)
        pyautogui.keyUp('f1')
    elif button == 'f2' or button == 'stats':
        pyautogui.keyDown('f2')
        RandTime.randomTime(2, 7)
        pyautogui.keyUp('f2')
    elif button == 'f4' or button == 'equipment':
        pyautogui.keyDown('f4')
        RandTime.randomTime(2, 7)
        pyautogui.keyUp('f4')
    elif button == 'f6' or button == 'magic':
        pyautogui.keyDown('f6')
        RandTime.randomTime(2, 7)
        pyautogui.keyUp('f6')
    elif button == 'f8' or button == 'friends':
        pyautogui.keyDown('f8')
        RandTime.randomTime(2, 7)
        pyautogui.keyUp('f8')

    elif button == 'exit' or button == 'inventory':
        pyautogui.keyDown('esc')
        RandTime.randomTime(2, 7)
        pyautogui.keyUp('esc')