Ejemplo n.º 1
0
def main():
    img = None
    main_win = Windows_handler.WinHandler(title='Nox',class_name='Qt5QWindowIcon')
    main_box = main_win.get_bbox()
    px_handler = Pixel_handler.PixelSearch(win_handler=main_win)
    mouse = Mouse_handler.MouseMovement(window_handler=main_win)
    main_win.init_window()
    cv2.namedWindow('image_name')
    cv2.namedWindow('config')

    while True:

        img = px_handler.grab_window(bbox=main_box)
        img = px_handler.img_to_numpy(img,compound=False)
        img = cv2.cvtColor(img,cv2.COLOR_RGB2BGR)

        orb = cv2.ORB_create()
        kp = orb.detect(img, None)
        kp, des = orb.compute(img, kp)
        img2 = cv2.drawKeypoints(img, kp)

        cv2.imshow('image_name',img2)
        cv2.setMouseCallback('image_name', mouse_event, param=img)


        k = cv2.waitKey(1)
        if k == ord('q'):  # wait for ESC key to exit
            cv2.destroyAllWindows()
            quit(0)
Ejemplo n.º 2
0
def multi_screen():
    wh = WindowHandlers.WinHandler("Netflix")
    print(wh.get_desktop_stats())
    px = PixelSearch.PixelSearch(win_handler=wh)

    mat = px.pixel_search(0xA87161, 12)
    Helpers.show_matrix(mat)
Ejemplo n.º 3
0
def search_for_pixels():
    wh = WindowHandlers.WinHandler()
    wh.set_target(title_name='Untitled - Notepad'
                  )  #desktop is a special case that is the primary monitor
    wh.init_window()
    px = PixelSearch.PixelSearch(wh)
    mx = px.pixel_search(0xFFFFFF, shades=50)
    Helpers.show_matrix(mx)
Ejemplo n.º 4
0
def move_window_around():
    os.system('calc.exe')  # Lets run the calculator app
    win_handler = WindowHandlers.WinHandler(
        title='Kalkulator')  # Init of the window handler
    window_pos = win_handler.get_bbox()
    for x in range(0, 800, 100):
        for y in range(300, 100, -50):
            win_handler.move((x, y))
            time.sleep(0.3)
Ejemplo n.º 5
0
 def test_pixel_search(self):
     logging.debug("Running pixelsearch test")
     win_handler = wh.WinHandler('Kalkulator')
     pixel_search = ps.PixelSearch(win_handler)
     win_handler.init_window(pos=(0, 0, 320, 510))
     sleep(1)
     im = Image.open('pixel_search_sample.png')
     array = np.array(im)
     print array
Ejemplo n.º 6
0
    def test_basic_commands(self):
        win_handler = wh.WinHandler()
        pixel_handler = ps.PixelSearch(win_handler)
        mouse_handler = mm.MouseMovement(win_handler)

        com = CommandAndControl(win_handler, pixel_handler, mouse_handler)

        com.use_UAV((0.5, 0.5))
        sleep(2)
        com.use_EMP((0.4, 0.4))
Ejemplo n.º 7
0
    def test_manipulate_ui(self):
        logging.debug('Starting UI test')

        win_handler = wh.WinHandler('Kalkulator')

        hwnd = win_handler.get_hwnd()
        style_base = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)

        win_handler.hide_extra_ui()
        style_removed = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        assert style_base != style_removed

        win_handler.hide_extra_ui(remove=False)
        style_added = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        assert style_removed != style_added
Ejemplo n.º 8
0
    def test_window_grab(self):
        logging.debug("Running pixel search test")

        win_handler = wh.WinHandler('Kalkulator')
        pixel_search = ps.PixelSearch(win_handler)
        win_handler.init_window(pos=[0, 0, 320, 510])
        sleep(1)
        pixel_search.grab_window('pixel_search.png')

        file = pixel_search.grab_window('pixel_search.png')
        im = Image.open('pixel_search_sample.png')
        im = Image.Image.crop(im, (20, 20, 200, 200))
        im.load()
        im2 = Image.Image.crop(file, (20, 20, 200, 200))
        im2.load()

        mat1 = im.tobytes()
        mat2 = im2.tobytes()
        assert (mat1 == mat2)
Ejemplo n.º 9
0
def click_and_drag():
    # Note this will not work if its the 64bit version of paint that starts

    os.system(f"start C:\Windows\System32\mspaint.exe")
    time.sleep(1)
    win_handler = WindowHandlers.WinHandler()
    win_handler.set_target(class_name='Afx:770000:8',
                           parent_class='MSPaintApp')
    win_handler.init_window()
    mouse_handler = MouseMovement.MouseMovement(win_handler)
    for _ in range(0, 100):
        bbox = win_handler.get_bbox()
        rand_w_s = random.randrange(0, bbox[2])
        rand_h_s = random.randrange(0, bbox[3])
        rand_w_e = random.randrange(0, bbox[2])
        rand_h_e = random.randrange(0, bbox[3])

        mouse_handler.hold_and_drag((rand_w_s, rand_h_s), (rand_w_e, rand_h_e),
                                    steps=5,
                                    button="left")
        time.sleep(0.05)
Ejemplo n.º 10
0
    def test_basic_commander(self):
        logging.debug("Running a basic test of the commander functions")

        parser = SafeConfigParser()
        parser.read('config.ini')
        color = parser.get('PixelScan', 'redColor')
        color = int(color, 16)
        win_handler = wh.WinHandler()
        pixel_search = ps.PixelSearch(win_handler)
        mouse_handler = mm.MouseMovement(win_handler)

        bbox = win_handler.get_bbox()
        bbox_size = win_handler.get_bbox_size()
        win_handler.init_window(borderless=True)
        sleep(0.1)

        px = pixel_search.pixel_search(color, shades=2, debug='check.png')

        places = np.nonzero(px)

        for hit in range(len(places[0])):
            mouse_handler.click((places[1][hit], places[0][hit]))
            sleep(1)
Ejemplo n.º 11
0
 def find_window(self):
     win_hwnd = WindowHandlers.WinHandler(title="Bluestacks")
     print(win_hwnd)
     print(win_hwnd.get_bbox())
     return win_hwnd