Exemple #1
0
    def _run(self):
        l = Listener(on_press=self._on_press)
        l.daemon = True
        l.start()

        t = threading.Thread(target=self._cleaner)
        t.daemon = True
        t.start()
Exemple #2
0
    def _run(self):
        l = Listener(on_press=self._on_press)
        l.daemon = True
        l.start()

        cleanerThread = Thread(target=self._cleaner)
        cleanerThread.daemon = True
        cleanerThread.start()
def main():
    global settings_file_path
    global settings_dict

    #making sure there is a default settings file, since I need to to restore to the default settings
    load_default_settings()
    dict_to_file(settings_dict, default_settings_file_path)

    try:
        settings_dict = file_to_dict(settings_file_path)
        print("the settings_dict", settings_dict)
        if len(settings_dict) < num_settings:
            raise Exception

    except Exception as e:
        print("main: something is wrong: ", e)
        error_handler("main: " + str(e))
        #load_default_settings()
        #create/save to the settings file
        #dict_to_file(settings_dict, default_settings_file_path)
        dict_to_file(settings_dict, settings_file_path)

    global mouse_controller
    global mouse_manager
    global key_board
    mouse_controller = Controller()
    mouse_manager = MouseClicker(mouse_controller)
    key_board = Listener(on_press=key_pressed)
    #so when the window closes, the thread will eventually ends
    key_board.daemon = True

    print("Clicker is now ready")
    a_thread = threading.Thread(target=mouse_manager.run_program, daemon=True)
    a_thread.start()

    key_board.start()

    #the gui part
    global clicker_gui
    clicker_gui = clicker_7_gui.ClickerGui(
        window_size=settings_dict['size'],
        settings_dict=settings_dict,
        default_settings_file_path=default_settings_file_path,
        user_settings_file_path=settings_file_path)
    clicker_gui.present()

    #if the window is closed, the program will then proceed, (the mainloop is now terminated)
    #save the changes to settings file

    settings_dict = clicker_gui.settings_dict
    dict_to_file(settings_dict, settings_file_path)
    mouse_manager.stop_clicking()
Exemple #4
0
def startscreenocr():  #截屏后剪切再ocr识图
    global flag_startscreenocr
    # 运行进程
    t5 = Listener(on_press=on_press_Pause)
    t5.daemon = True
    t6 = threading.Thread(target=press_Pause, name='ocr')
    t6.daemon = True
    if flag_startscreenocr == 0:
        t5.start()
        t6.start()
        flag_startscreenocr = 1
    elif flag_startscreenocr == 1:
        #stop_thread(t1)
        #stop_thread(t2)
        flag_startscreenocr = 0
Exemple #5
0
def startscreen():  #只截全屏
    global flag_startscreen
    # 运行进程
    t3 = Listener(on_press=on_press_ScrollLock)
    t3.daemon = True
    t4 = threading.Thread(target=press_ScrollLock, name='screen')
    t4.daemon = True
    if flag_startscreen == 0:
        t3.start()
        t4.start()
        flag_startscreen = 1
    elif flag_startscreen == 1:
        #stop_thread(t3)
        #stop_thread(t4)
        flag_startscreen = 0
Exemple #6
0
def startscreenShot():  #截屏后剪切
    global flag_startscreenShot
    # 运行进程
    t1 = Listener(on_press=on_press_PrintScreen)
    t1.daemon = True
    t2 = threading.Thread(target=press_PrintScreen, name='screenShot')
    t2.daemon = True
    if flag_startscreenShot == 0:
        t1.start()
        t2.start()
        flag_startscreenShot = 1
    elif flag_startscreenShot == 1:
        #stop_thread(t1)
        #stop_thread(t2)
        flag_startscreenShot = 0
Exemple #7
0
def start():
    global flag,flag_switch

    # 运行进程
    t1 = Listener(on_press=on_press_s)
    t1.daemon = True
    t2 = threading.Thread(target=press_s, name='sendThreads')
    t2.daemon = True
    if flag == 0:
        t1.start()
        t2.start()
        flag = 1
    elif flag == 1:
        stop_thread(t1)
        stop_thread(t2)
        flag = 0
Exemple #8
0
def start_1():
    global flag_1

    # 运行进程
    t1 = Listener(on_press=on_press_start_1)
    t1.daemon = True
    t2 = threading.Thread(target=press_stop_1, name='sendThreads_1')
    t2.daemon = True
    if flag_1 == 0:
        t1.start()
        t2.start()
        flag_1 = 1
    elif flag_1 == 1:
        stop_thread(t1)
        stop_thread(t2)
        flag_1 = 0
Exemple #9
0
def get_unix_keys(queue):
    if platform_name != 'Windows':

        def on_release(key):
            unix_keys = []

            if key == Key.space:
                unix_keys.append(' ')
                queue.put(unix_keys)
            else:
                try:
                    unix_keys.append(key.char)
                    queue.put(unix_keys)
                    if key.char == 'q':
                        return False
                except:
                    pass

        listener = Listener(on_release=on_release)
        listener.daemon = True
        listener.start()
        listener.join()
Exemple #10
0
def hotkey():
    #Thread that listens for the ctrl key
    listener = Listener(on_press=on_press, on_release=on_release)
    listener.daemon = True
    listener.start()
Exemple #11
0
def hotkey():
    listener = Listener(on_press=on_press, on_release=on_release)
    listener.daemon = True
    listener.start()
Exemple #12
0
        DisplayModule.DisplayTexts(displayTexts)

    if H.__verbose__ or not H.__raspberry__:
        print("--------------------")
        for i in range(C.LCD_LEN):
            print(displayTexts[i])
        print("--------------------")


# Other Setups
RunModule.SetDisplayLCDCallback(DisplayLCD)
##############

# Start key listener. Use `on_press` and `on_release` as button press handlers.
keyListener = Listener(on_press=on_press, on_release=on_release)
keyListener.daemon = True
keyListener.start()

if H.__verbose__:
    print("Key Listener Started")

try:
    while (1):
        if currentState in [STATE.PWM, STATE.PWM_SEQUENCE, STATE.PWM_MATRIX]:
            DisplayLCD()

        time.sleep(1)
except KeyboardInterrupt:
    if H.__raspberry__:
        RS.cleanup()
    print("Program terminated")
Exemple #13
0
        env.set_action_keys(['y','u','h','j','k','l','b','n','<','>','er\x1b'])
    elif arg == '-debug':
        log_level = logging.DEBUG
    elif arg == '-debug-crawl-env':
        logging.getLogger('crawl-env').setLevel(logging.DEBUG)
    elif arg == '-debug-term-capture':
        logging.getLogger('term-capture').setLevel(logging.DEBUG)

logging.basicConfig(filename='test-env.log', filemode='w', level=log_level, format='%(asctime)s:%(levelname)s:%(module)s:%(message)s')

if render:
    sys.stdout.write(tc.ESC_CLEAR_SCREEN)

# listener for detecting escape key press
listener = Listener(on_press=on_press)
listener.daemon = True # thread dies with the program
listener.start()

# Each of these is its own game.
for episode in range(5):
    env.reset()
    score = 0
    steps = 0
    done = False
    while not done:

        if exit_requested.is_set():
            sys.exit()

        # Pick a random action
        action = env.action_space.sample()
Exemple #14
0
def start_2():
    # 运行进程
    t3 = Listener(on_press=on_press_start_2)
    t3.daemon = True
    t3.start()