Exemplo n.º 1
0
                    break

                no_focus += 1

            wm_class = "(" + w_class[0] + "," + w_class[1] + ")"

            if w_name != window_event.wm_name or wm_class != window_event.wm_class:
                window_event = WindowChangeEvent(time.time(), w_name, w_class, (app_x, app_y),
                                                 (app_w, app_h))
                os.chdir(wd)
                with open(output_dir + "/test.log", "a+") as f:
                    f.write(window_event.hashcode() + "\n")

                print(window_event.hashcode())

            window_model = user_model.get_window_model(window_event.wm_name)

            if window_model == None or (cfg.fallback == "random" and window_model == user_model.default_model):

                event = event_constructor.random_event()

                event.change_window(window_event)
                seeding_key = True
                event.perform()
                seeding_key = False
                time.sleep(event.get_delay())

                t = Thread(target=capture_screen)
                t.start()

                with open(output_dir + "/test.log", "a+") as f:
Exemplo n.º 2
0
    output = "."

    if len(sys.argv) > 4:
        output = sys.argv[4]

    with open(file, "rb") as f:
        user_model = pickle.load(f)

    screenshot_file = sys.argv[2]

    screenshot = cv2.imread(screenshot_file)

    window_title = sys.argv[3]

    output += "/" + window_title

    w_m = user_model.get_window_model(window_title)

    if w_m == user_model.default_model:
        print("Window model not found for title: '" + window_title + "'.")
        screen_app_model = create_img(user_model.default_model, screenshot)

        cv2.imwrite(output + "-one-out.png", screen_app_model)
    else:

        screen_app_model = create_img(user_model.default_model, screenshot)
        screen_window_model = create_img(w_m, screenshot)

        cv2.imwrite(output + "-app.png", screen_app_model)
        cv2.imwrite(output + "-window.png", screen_window_model)