Exemplo n.º 1
0
 def move_humanly_mouse_random_location_in_box(box):
     hc = HumanClicker()
     box = Box(box)
     delta_x = randint(0, box.width())
     delta_y = randint(0, box.height())
     to_location = (int(box.x() + delta_x), int(box.y() + delta_y))
     hc.move(to_location, 0.5)
Exemplo n.º 2
0
def run():
    hc = HumanClicker()
    # While there's no 'execution stop' command passed
    while exec_stop is False:
        # If the script is in autoclicker mode
        if mode == "autoclicker":
            try:
                # Configure positions based on your screen
                hc.move((840, 710), 1)
                hc.click()
                time.sleep(5)
                hc.move((841, 583), 1)
                hc.click()
                time.sleep(5)
                hc.move((693, 667), 1)
                hc.click()
                time.sleep(5)
            except:
                # If an error occurred
                print("An error occurred: ", sys.exc_info()[0])
                sys.exit(0)
        # If the script is in position logger mode
        else:
            try:
                # Print position to console every second
                print(pyautogui.position())
                time.sleep(1)
            except:
                # If an error occurred
                print("An error occurred: ", sys.exc_info()[0])
Exemplo n.º 3
0
 def __init__(self, hwnd, x, y, w, h):
     self.hc = HumanClicker()
     self.hwnd = hwnd
     self.x = x
     self.y = y
     self.w = w
     self.h = h
     self.range = hand_pick_range()
Exemplo n.º 4
0
def run_recovery(logger):
    # base_map_file_path = r"C:\temp\test\ca8b7525-9399-42f7-9eee-c0fdf0431b06.png"
    # client_map_file_path = r"C:\temp\templates\seer_village_bank.png"
    # match_coordinates = match_images(base_map_file_path, client_map_file_path,show_box=True)
    # if match_coordinates is None:
    #     pass
    # print "YES", match_coordinates

    hc = HumanClicker()

    game_window = RunescapeWindow(logger=logger)
    game_window.set_main_client_data()

    pprint(game_window.get_client_main_data())
    base_client_info = game_window.get_client_main_data()

    # base_map_file_path = r"C:\temp\test\ca8b7525-9399-42f7-9eee-c0fdf0431b06.png"
    # base_map_file_path = base_client_info.get("MapFile")

    # for client_name, client_info in base_client_info.iteritems():
    for client_name, client_info in base_client_info.items():
        logger.info("run recovery on {0}".format(client_name))
        base_info = base_client_info.get(client_name)
        base_map_file_path = base_info.get("MapFile")
        # base_map_file_path = "C:/temp/test/edaeac32-edf2-42af-ac74-ac6db88b5ec3.png"
        bank_anchor_file = r"C:\temp\templates\seer_village_bank.png"
        match_coordinates = match_images(base_map_file_path,
                                         bank_anchor_file,
                                         show_box=True)
        if match_coordinates is None:
            logger.info("Recovery has failed. Ending Script")
            continue
        else:
            click_loc = tuple(
                map(operator.add, base_info.get("ClientLoc"),
                    base_info.get("GamePlayLocByClient")))
            click_loc = tuple(
                map(operator.add, click_loc,
                    base_info.get("MapLocByGamePlay")))
            click_loc = tuple(map(operator.add, click_loc, match_coordinates))
            click_loc = tuple(map(operator.add, click_loc, (6, 16, 7, 16)))

            hc.move((click_loc[0], click_loc[1]), 2)
Exemplo n.º 5
0
 def init(cls):
     cls.hc = HumanClicker()
Exemplo n.º 6
0
    square_mar_he = board_height / 8

    if who == "b":
        x_square1 = 9 - (ord(str(move)[0]) - 96)
        y_square1 = int(str(move)[1])
        x_square2 = 9 - (ord(str(move)[2]) - 96)
        y_square2 = int(str(move)[3])
    else:
        x_square1 = ord(str(move)[0]) - 96
        y_square1 = 9 - int(str(move)[1])
        x_square2 = ord(str(move)[2]) - 96
        y_square2 = 9 - int(str(move)[3])

    if legit == "y":
        time.sleep(random.randint(1, 35) / 10)
        hc = HumanClicker()
        curve = HumanCurve(
            pyautogui.position(),
            (round(board_pos[0] +
                   (square_mar_wi * x_square1) - square_mar_wi / 2) -
             random.randint(-13, 13),
             round(board_pos[1] +
                   (square_mar_he * y_square1) - square_mar_he / 2) -
             random.randint(-13, 13)),
            distortionFrequency=0,
            tweening=pytweening.easeInOutQuad,
            offsetBoundaryY=8,
            offsetBoundaryX=8,
            targetPoints=random.randint(30, 40))
        hc.move((round(board_pos[0] +
                       (square_mar_wi * x_square1) - square_mar_wi / 2),
Exemplo n.º 7
0
from status import Status_Bar
from pyclick import HumanClicker  # super symulacja ruchu myszki
import pyautogui
import time
import random
import find_in_box
from lib.window import Window

mouse = HumanClicker()
status = Status_Bar()
mode = input("What kind of mining are you planing to do? w(wall)/v((vein)")

count = 0
while True:
    if mode == "v" or pyautogui.locateOnScreen(
            'media/title-window/cave_wall.png', confidence=.8):
        if status.stamin:

            pyautogui.typewrite('l')
            count += 1
            time.sleep(random.random() * 2)

            if mode == "v" and count >= random.randint(10, 50):
                pyautogui.typewrite('l')
                time.sleep(random.random())
                pyautogui.typewrite('l')
                time.sleep(random.random())
                pyautogui.typewrite('l')

                pile_of_items = Window(
                    title='media/box-titles/pile-of-items.png')
Exemplo n.º 8
0
def main_run():
    # loop while waiting on emey to die
    def wait_loop():
        health_counter = 1
        enemy = Enemy()
        #waits until enemy health is 0
        start_time = time.time()
        while health_counter != 50:
            enemy.getHealth()
            cv2.imshow('health-hsv', enemy.health_img)
            cv2.imshow('mask', enemy.mask)
            cv2.waitKey(1)
            if enemy.health == 0:
                #time.sleep(random())
                print(
                    f'Fight took:{time.time()-start_time:.2f} secs\nHealth Counter={health_counter}'
                )
                health_counter = 1
                return
            health_counter += 1
            #time.sleep(1+random())

    # initialize HumanClicker object
    hc = HumanClicker()

    #dark_wizard = [ [27,70,22], [28,107,64] ]
    #hill giant
    dark_wizard = [[20, 46, 34], [33, 106, 72]]
    green_tile = [[61, 113, 105], [68, 255, 255]]
    # low high hsv values
    player_tile = [[87, 232, 190], [90, 255, 255]]
    #gree_health_bar = [ [54,108,120],[62,255,255]]
    #red_health_bar = [ [0,254,254],[1,255,255] ]
    secs_wait = 1
    while 1:
        playScreen = Screenshot.shoot(0, 0, 520, 360, 'hsv')

        low = np.array(green_tile[0])
        high = np.array(green_tile[1])
        mask = cv2.inRange(playScreen, low, high)

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

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

        areas = {}
        # gathers areas with center coords
        for con in (contours):
            area = cv2.contourArea(con)
            if area > 50:
                M = cv2.moments(con)
                #print(area)
                cx = int(M['m10'] / M['m00'])
                cy = int(M['m01'] / M['m00'])
                areas[area] = (cx, cy)
        # restarts loop if no emenies around
        if len(areas.keys()) == 0:
            print(f'No enemy detected...waiting {secs_wait} secs...')
            time.sleep(secs_wait)
            secs_wait += secs_wait * .20
            continue
        # find distance to 260,180 coords.  which is center of playing screen
        distances = {}
        for ele_set in areas.items():
            x = ele_set[1][0]
            y = ele_set[1][1]
            dist = int(sqrt(((260 - x)**2) + ((180 - y)**2)))
            distances[dist] = areas[ele_set[0]]
        # select point with min distance to center of play screen
        min_distance = min([i for i in distances.keys()])
        #print(f'minimum distance:{min_distance}')
        #print(f'coords:{distances[min_distance]}')

        # unpacks coords of tile closest to center of screen
        cx, cy = distances[min_distance]

        # move the mouse to position (100,100) on the screen in approximately 2 seconds
        hc.click(x=cx, y=cy)
        #autopy.mouse.move(cx,cy)
        #Mouse.moveTo(cx,cy)
        # wait after clicking to be able to see health box on top top of playscreen
        # time.sleep(2)
        # wait_loop()
        time.sleep(triangular(14, 29) / 1.5)
        # resets time to wait
        secs_wait = 1
Exemplo n.º 9
0
	def __init__(self, title_img):
		self.__title_img = title_img
		self.move = HumanClicker()
Exemplo n.º 10
0
 def __init__(self, setupwindow=True):
     # object contains window ID and x,y positions
     self.rs_window = setup.Window(setupwindow=setupwindow)
     self.rsx, self.rsy = self.rs_window.position
     self.hc = HumanClicker()
Exemplo n.º 11
0
 def move_humanly_mouse_to_location(x, y):
     hc = HumanClicker()
     hc.move((int(x), int(y)), 0.5)