コード例 #1
1
ファイル: _keyboard_tests.py プロジェクト: boppreh/keyboard
    def test_press_release(self):
        keyboard.press("a")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "a")])
        keyboard.release("a")
        self.assertEqual(self.flush_events(), [(KEY_UP, "a")])

        keyboard.press("shift+a")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "shift"), (KEY_DOWN, "a")])
        keyboard.release("shift+a")
        self.assertEqual(self.flush_events(), [(KEY_UP, "a"), (KEY_UP, "shift")])

        keyboard.press_and_release("a")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "a"), (KEY_UP, "a")])
コード例 #2
0
def move_to_bank():
    random_x_interval = random.uniform(1206, 1253)
    random_y_interval = random.uniform(473, 626)

    pyautogui.moveTo(random_x_interval, random_y_interval, 1)

    #pyautogui.doubleClick(interval=random.uniform(0.2, 0.4))
    pyautogui.click(clicks=2, interval=random.uniform(0.2, 0.3))
    time.sleep(random_preset_delay)
    pyautogui.click(clicks=2, interval=random.uniform(0.2, 0.3))
    time.sleep(interface_delay)

    keyboard.press("F1")
    time.sleep(random_preset_delay)
    keyboard.release("F1")
コード例 #3
0
def survive():
    n = 0
    while True:
        if survival_activated and "diep.io" in get_foreground_window_title():
            keyboard.press("a")
            time.sleep(2)
            keyboard.release("a")
            keyboard.press("d")
            time.sleep(2)
            keyboard.release("d")
            time.sleep(2)
            n += 1
            if n % 10 == 0:
                take_pic()
        time.sleep(10)
コード例 #4
0
    def test_press_release(self):
        keyboard.press('a')
        self.assertEqual(self.flush_events(), [(KEY_DOWN, 'a')])
        keyboard.release('a')
        self.assertEqual(self.flush_events(), [(KEY_UP, 'a')])

        keyboard.press('shift+a')
        self.assertEqual(self.flush_events(), [(KEY_DOWN, 'shift'),
                                               (KEY_DOWN, 'a')])
        keyboard.release('shift+a')
        self.assertEqual(self.flush_events(), [(KEY_UP, 'a'),
                                               (KEY_UP, 'shift')])

        keyboard.press_and_release('a')
        self.assertEqual(self.flush_events(), [(KEY_DOWN, 'a'), (KEY_UP, 'a')])
コード例 #5
0
def zoom(transcript):
    in_or_out = transcript.split()
    if in_or_out[1] == "in":
        keyboard.press("ctrl")
        sleep()
        mouse.wheel(delta=5)
        sleep()
        keyboard.release("ctrl")

    elif in_or_out[1] == "out":
        keyboard.press("ctrl")
        sleep()
        mouse.wheel(delta=-5)
        sleep()
        keyboard.release("ctrl")
コード例 #6
0
def login_process(client_full_path, char_on_acc_total, position_on_char_list):
    open_new_client(client_full_path)

    sleep(3)
    keyboard.press("enter")
    keyboard.release("enter")
    sleep(3)
    #for i in range(char_on_acc_total):
    #    keyboard.press("up") # Presses "up" key
    #    keyboard.release("up") # Releases "up" key
    #    sleep(1)

    keyboard.press("enter")
    keyboard.release("enter")
    sleep(1)
def move_to_bank():
    random_x_interval = random.uniform(927, 1064)
    random_y_interval = random.uniform(750, 790)

    pyautogui.moveTo(random_x_interval, random_y_interval, 1)

    #pyautogui.doubleClick(interval=random.uniform(0.2, 0.4))
    pyautogui.click(clicks=1, interval=random.uniform(0.2, 0.3))
    time.sleep(random.uniform(0.4, 0.6))
    pyautogui.click(clicks=2, interval=random.uniform(0.2, 0.3))
    time.sleep(interface_delay)

    keyboard.press("F1")
    time.sleep(random_preset_delay)
    keyboard.release("F1")
コード例 #8
0
ファイル: bot.py プロジェクト: kotoskar/RF4-Bot
def bind_tea():
    kb.press('t')
    t.sleep(2)
    try:
        tea_location = pg.locateCenterOnScreen('images/tea.png',
                                               confidence=0.75)
        if tea_location != None:
            pg.moveTo(tea_location)
            pg.dragTo(200, 850, 1)
        else:
            print('no tea found(')
    except:
        return bind_tea()
    t.sleep(0.75)
    kb.release('t')
コード例 #9
0
def execute_commands(accel, brake, enCruise, upCruise, dwnCruise):
    global current_cruise
    if accel: keyboard.press(key_accel)
    if brake: keyboard.press(key_brake)
    if enCruise:
        keyboard.press_and_release(key_cruise)
        current_cruise = current_speed
    if upCruise:
        keyboard.press_and_release(key_cruise_up)
        current_cruise += step
    if dwnCruise:
        keyboard.press_and_release(key_cruise_dwn)
        current_cruise -= step

    if not accel: keyboard.release(key_accel)
    if not brake: keyboard.release(key_brake)
コード例 #10
0
def action(j_data, past_j_data):
    if past_j_data == None:
        return

    # deal with button
    if ((j_data["Acc_y"] * DownScaler) > x_threshold):
        kb.press(keyDict["Up"])
    elif ((j_data["Acc_y"] * DownScaler) < x_threshold):
        kb.release(keyDict["Up"])

    if ((j_data["Acc_y"] * DownScaler) < -1 * x_threshold):
        kb.press(keyDict["Down"])
    elif ((j_data["Acc_y"] * DownScaler) > -1 * x_threshold):
        kb.release(keyDict["Down"])

    return
コード例 #11
0
ファイル: actions.py プロジェクト: cplant1776/Dumb-Game-Bot
    def move(self, direction='forward', duration=0.0):
        """Moves the character in given direction for the given duration


        arguments
        ---------
        direction - accepts "left", "right", "forward", "backward" and uses it as dict key for self.move_dir
        duration - how long to hold the movement key
        """
        # Depress proper movement key
        keyboard.press(self.move_dir[direction])

        # After duration, release key
        if duration > 0.0:
            sleep(duration)
            keyboard.release(self.move_dir[direction])
コード例 #12
0
ファイル: moves.py プロジェクト: arruda/magic_it_up
def press_keys(keys):
    global PRESSED_KEYS
    keys = validate_keys(keys)

    keys_to_release = prepare_release_keys_list(keys)
    if len(keys_to_release) != 0:
        keyboard.release(",".join(keys_to_release))
        PRESSED_KEYS.difference_update(set(keys_to_release))

    new_keys = prepare_new_keys_to_press(keys)
    if len(new_keys) != 0 and '' not in new_keys:
        PRESSED_KEYS.update(keys)
        keys_to_press = ",".join(new_keys)
        keyboard.press(keys_to_press)

    logger.debug("current pressed keys: %s" % PRESSED_KEYS)
コード例 #13
0
def play(events,
         speed_factor=2,
         include_clicks=True,
         include_moves=True,
         include_wheel=True):
    state = key.stash_state()
    last_time = None
    for event in events:

        if speed_factor > 0 and last_time is not None:
            time.sleep((event.time - last_time) / speed_factor)
        last_time = event.time

        # F12 를 누르면 play중 종료
        val = key.is_pressed('F12')
        if val == True:
            key.restore_modifiers(state)
            return

        if isinstance(event, mo.ButtonEvent) and include_clicks:
            if event.event_type == mo.UP:
                mo._os_mouse.release(event.button)
            else:
                mo._os_mouse.press(event.button)
        elif isinstance(event, mo.MoveEvent) and include_moves:
            mo._os_mouse.move_to(event.x, event.y)
        elif isinstance(event, mo.WheelEvent) and include_wheel:
            mo._os_mouse.wheel(event.delta)
        else:
            valkey = event.name
            key.press(
                valkey) if event.event_type == key.KEY_DOWN else key.release(
                    valkey)

    key.restore_modifiers(state)
コード例 #14
0
ファイル: main.py プロジェクト: yedhrab/InputRecorder
    def _play(self, speed_factor=7.0, include_clicks=True, include_moves=True, include_wheel=True):
        # For hotkey management
        state = keyboard.stash_state()

        last_time = None
        for event in self.events:
            if speed_factor > 0 and last_time is not None:
                time.sleep((event.time - last_time) / speed_factor)
            last_time = event.time

            if isinstance(event, KeyboardEvent):
                key = event.scan_code or event.name
                keyboard.press(key) if event.event_type == KEY_DOWN else keyboard.release(key)

            if isinstance(event, ButtonEvent) and include_clicks:
                if event.event_type == UP:
                    mouse.release(event.button)
                else:
                    mouse.press(event.button)
            elif isinstance(event, MoveEvent) and include_moves:
                mouse.move(event.x, event.y)
            elif isinstance(event, WheelEvent) and include_wheel:
                mouse.wheel(event.delta)

        # For hotkey management
        keyboard.restore_modifiers(state)
コード例 #15
0
    def launch_cam(self):
        time.sleep(2)

        # Wait for the camera is available
        while self.is_disconet_msg():
            self.acknowledge_disconect()
            self.refresh()
            time.sleep(1)

        # launch of the final Remote Window
        while self.is_pre_remote():
            self.click(89, 78, True)
            time.sleep(3)
            keyboard.press('Enter')
            time.sleep(0.2)
            keyboard.release('Enter')
コード例 #16
0
def focus(cur_foc):
    if int(cur_foc) != 0:
        if (cur_foc > 0):
            keyboard.press('ctrl')
            time.sleep(.01)
            mouse.wheel(1)
            cur_foc -= 1
        elif (cur_foc < 0):
            keyboard.press('ctrl')
            time.sleep(.01)
            mouse.wheel(-1)
            cur_foc += 1
        time.sleep(.01)
        keyboard.release('ctrl')

    return cur_foc
コード例 #17
0
ファイル: play.py プロジェクト: joshuaskelly/twitch-player
    def press_and_release(hotkey, hold_time=0.0):
        """Press the given hotkey for the specified time and then release.

        Note:
            Some programs might not register a key press if the hold time is
            zero.

        :param hotkey: The key to press
        :param hold_time: The length of time in seconds to hold the key.
        """
        keyboard.press(hotkey)

        if hold_time > 0:
            time.sleep(hold_time)

        keyboard.release(hotkey)
コード例 #18
0
    def run(self):
        # Reset talk release
        self.talk_release_is_pending = False
        # Create audio streams

        input_stream = DeviceInputStream(self.input_device)
        output_stream = DeviceOutputStream(self.output_device)
        if self.playback_device != None:
            playback_stream = DeviceOutputStream(self.playback_device)

        if self.enable_burst:
            keyboard.on_release_key(self.talk_key,
                                    self.handle_release_talk,
                                    suppress=True)

        # Run voice changer
        while self.is_active:
            talk_is_active = keyboard.is_pressed(self.talk_key)
            burst_is_active = self.enable_burst and talk_is_active == False and (
                time.time() - self.last_talk_release_time
            ) < self.burst_sound.duration_seconds
            audio_is_active = talk_is_active or burst_is_active
            keyboard_needs_release = self.talk_release_is_pending and burst_is_active == False
            elapsed = time.time() - self.start_time

            if audio_is_active:
                # Get sound from microphone
                sound = input_stream.read(self.chunk_size)

                # Add overlays and transformations
                sound = (sound + 15).equalize().overlay_using_start_time(
                    self.static_sound - 25,
                    elapsed % self.static_sound.duration_seconds)
                if (burst_is_active):
                    sound = sound.overlay_using_start_time(
                        self.burst_sound - 5,
                        time.time() - self.last_talk_release_time)

                # Play
                if self.playback_device != None:
                    playback_stream.play(sound)
                output_stream.play(sound)

            elif keyboard_needs_release:
                # Trigger delayed talk key release
                keyboard.release(self.talk_key)
                self.talk_release_is_pending = False
コード例 #19
0
ファイル: main.py プロジェクト: stopwithfailure/b-b
    def Op(key, op, ox, oy):
        # print(key, op, ox, oy)
        if key == 1:
            if op == 100:

                # 左键按下
                mouse.move(ox, oy)
                mouse.press(button=mouse.LEFT)
            elif op == 117:

                # 左键弹起
                x, y = mouse.get_position()
                if ox != x or oy != y:
                    if not mouse.is_pressed():
                        mouse.press(button=mouse.LEFT)
                    mouse.move(ox, oy)
                mouse.release(button=mouse.LEFT)
        elif key == 2:

            # 滚轮事件
            if op == 0:
                # 向上
                mouse.move(ox, oy)
                mouse.wheel(delta=-1)
            else:
                # 向下
                mouse.move(ox, oy)
                mouse.wheel(delta=1)

        elif key == 3:
            # 鼠标右键
            if op == 100:
                # 右键按下
                mouse.move(ox, oy)
                mouse.press(button=mouse.RIGHT)
            elif op == 117:
                # 右键弹起
                mouse.move(ox, oy)
                mouse.release(button=mouse.RIGHT)

        else:
            k = official_virtual_keys.get(key)
            if k is not None:
                if op == 100:  # 按键按下
                    keyboard.press(k)
                elif op == 117:  # 按键抬起
                    keyboard.release(k)
コード例 #20
0
ファイル: Diablo2Functions.py プロジェクト: Maboey/Diablo2Bot
def LookForAndAttackRedEnemy():
    enemyFound = False
    enemyPosition = [0, 0]
    screenSize = FI.GetScreenSize()
    rangeHitAroundPlayer = 100
    pixels = FI.GetScreenPixels()
    rangeHitAroundPlayerStartingX = (screenSize[0] // 2) - rangeHitAroundPlayer
    rangeHitAroundPlayerStartingY = (screenSize[1] // 2) - rangeHitAroundPlayer
    for x in range(rangeHitAroundPlayer * 2):
        for y in range(rangeHitAroundPlayer * 2):
            pixel0 = pixels[rangeHitAroundPlayerStartingX + 0 + x,
                            rangeHitAroundPlayerStartingY + y + 0]
            pixel1 = pixels[rangeHitAroundPlayerStartingX + 1 + x,
                            rangeHitAroundPlayerStartingY + y + 0]
            pixel2 = pixels[rangeHitAroundPlayerStartingX + 2 + x,
                            rangeHitAroundPlayerStartingY + y + 0]
            pixel3 = pixels[rangeHitAroundPlayerStartingX + 0 + x,
                            rangeHitAroundPlayerStartingY + y + 1]
            pixel4 = pixels[rangeHitAroundPlayerStartingX + 1 + x,
                            rangeHitAroundPlayerStartingY + y + 1]
            pixel5 = pixels[rangeHitAroundPlayerStartingX + 2 + x,
                            rangeHitAroundPlayerStartingY + y + 1]
            pixel6 = pixels[rangeHitAroundPlayerStartingX + 0 + x,
                            rangeHitAroundPlayerStartingY + y + 2]
            pixel7 = pixels[rangeHitAroundPlayerStartingX + 1 + x,
                            rangeHitAroundPlayerStartingY + y + 2]
            pixel8 = pixels[rangeHitAroundPlayerStartingX + 2 + x,
                            rangeHitAroundPlayerStartingY + y + 2]
            pixelArrow = [
                pixel0, pixel1, pixel2, pixel3, pixel4, pixel5, pixel6, pixel7,
                pixel8
            ]
            for p in pixelArrow:
                if p[0] > 100 and p[1] < 40 and p[2] < 40:
                    enemyPosition = [
                        rangeHitAroundPlayerStartingX + x + 2,
                        rangeHitAroundPlayerStartingY + y + 2
                    ]
                    enemyFound = True
                    break
    if enemyFound:
        # hold shift to prevent character movement and release after attack
        keyboard.press("shift")
        FI.ClickXY(enemyPosition[0], enemyPosition[1])
        keyboard.release("shift")
        time.sleep(0.2)
    return enemyFound
コード例 #21
0
ファイル: controller.py プロジェクト: hallowslab/gd-ai
    def predict(self):
        sct = mss()
        coords = {
            "top": self.top,
            "left": self.left,
            "width": self.width,
            "height": self.height,
        }

        # image capture
        img = np.array(sct.grab(coords))

        # cropping, edge detection, resizing to fit expected model input
        img = img[::, 75:615]
        img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        img = cv2.Canny(img, threshold1=100, threshold2=200)
        img = cv2.resize(img, (0, 0), fx=0.5, fy=0.5)
        img = img[np.newaxis, :, :, np.newaxis]
        # img = np.array(img)

        # forward, jump, duck
        # [0,0,0]

        # model prediction
        y_prob = self.model.predict(img / 255)
        print(y_prob)
        prediction = y_prob.argmax(axis=-1)
        # print(prediction)

        if int(prediction) == 1:
            # jump
            sys.stdout.write("jump\n")
            # time.sleep(0.1)
            keyboard.press("up arrow")
            time.sleep(0.09)
            keyboard.release("up arrow")
        elif int(prediction) == 0:
            # do nothing
            # sys.stdout.write("walk\n")
            pass
        elif int(prediction) == 2:
            # duck
            sys.stdout.write("duck\n")
            keyboard.press("down arrow")
            time.sleep(0.25)
            keyboard.release("down arrow")
コード例 #22
0
def main():
    time.sleep(1.5)
    while not keyboard.is_pressed('ctrl+c'):
        time.sleep(1)
        # keyboard.press_and_release('w')

        keyboard.press('w')
        time.sleep(0.1)
        keyboard.release('w')

        time.sleep(1)

        keyboard.press('s')
        time.sleep(0.1)
        keyboard.release('s')

        time.sleep(1)
コード例 #23
0
def superMarioController():
    translate = {0: 'space', 2: 'down', 4: 'left', 6: 'right', 8: 'up'}
    opposite = {2: 8, 4: 6, 6: 4, 8: 2, 0: 0}
    otherkey = {2: [4, 6], 4: [2, 8], 6: [2, 8], 8: [4, 6], 0: [2, 4, 6, 8]}
    pressedkey = None
    keypress = False
    previousPrediction = 0
    while True:

        #Process commands
        if len(glb.predictions) > 1:
            with glb.predictionslock:
                prediction = glb.predictions[0]
                glb.predictions.pop(0)
            #Statemachine
            if (prediction in [2, 4, 6, 8]) and (keypress == False):  #Press
                pressedkey = prediction
                keyboard.press(translate[pressedkey])
                print("Pressed " + str(translate[pressedkey]))
                keypress = True

            if prediction == 0:
                if previousPrediction != 0:
                    keyboard.press_and_release(translate[prediction])
                    print("Press and release " + str(translate[prediction]))

            if (pressedkey != None) and (prediction != 0):

                if prediction == opposite[pressedkey]:  #Release
                    keypress = False
                    keyboard.release(translate[pressedkey])
                    print("Release " + str(translate[pressedkey]))

                elif prediction in otherkey[
                        pressedkey]:  #Release and press new
                    keypress = True
                    oldkey = copy.copy(pressedkey)
                    pressedkey = prediction
                    keyboard.release(translate[oldkey])
                    keyboard.press(translate[pressedkey])
                    print("Release " + str(translate[oldkey]) + "Press " +
                          str(translate[pressedkey]))

            previousPrediction = prediction

        tme.sleep(0.01)
コード例 #24
0
    def send_keystroke(self, key_instructions):
        if not isinstance(key_instructions, list):
            raise Exception(
                f"Expected list of keystroke actions, got {type(key_instructions)}"
            )

        for key_instruction in key_instructions:
            if key_instruction['action'] == 'press':
                keyboard.press(key_instruction['key'])
            elif key_instruction['action'] == 'press_and_release':
                keyboard.press(key_instruction['key'])
                time.sleep(0.1)
                keyboard.release(key_instruction['key'])
            elif key_instruction['action'] == 'release':
                keyboard.release(key_instruction['key'])
            else:
                raise Exception("Invalid Instruction to act upon")
コード例 #25
0
ファイル: Diablo2Functions.py プロジェクト: Maboey/Diablo2Bot
def LookForAndGrabItems():
    keyboard.press("alt")
    itemFound = False
    itemPosition = [0, 0]
    screenSize = FI.GetScreenSize()
    rangeHitAroundPlayer = 200
    pixels = FI.GetScreenPixels()
    rangeHitAroundPlayerStartingX = (screenSize[0] // 2) - rangeHitAroundPlayer
    rangeHitAroundPlayerStartingY = (screenSize[1] // 2) - rangeHitAroundPlayer
    for x in range(rangeHitAroundPlayer * 2):
        for y in range(rangeHitAroundPlayer * 2):
            pixel0 = pixels[rangeHitAroundPlayerStartingX + 0 + x,
                            rangeHitAroundPlayerStartingY + y + 0]
            pixel1 = pixels[rangeHitAroundPlayerStartingX + 1 + x,
                            rangeHitAroundPlayerStartingY + y + 0]
            pixel2 = pixels[rangeHitAroundPlayerStartingX + 2 + x,
                            rangeHitAroundPlayerStartingY + y + 0]
            pixel3 = pixels[rangeHitAroundPlayerStartingX + 0 + x,
                            rangeHitAroundPlayerStartingY + y + 1]
            pixel4 = pixels[rangeHitAroundPlayerStartingX + 1 + x,
                            rangeHitAroundPlayerStartingY + y + 1]
            pixel5 = pixels[rangeHitAroundPlayerStartingX + 2 + x,
                            rangeHitAroundPlayerStartingY + y + 1]
            pixel6 = pixels[rangeHitAroundPlayerStartingX + 0 + x,
                            rangeHitAroundPlayerStartingY + y + 2]
            pixel7 = pixels[rangeHitAroundPlayerStartingX + 1 + x,
                            rangeHitAroundPlayerStartingY + y + 2]
            pixel8 = pixels[rangeHitAroundPlayerStartingX + 2 + x,
                            rangeHitAroundPlayerStartingY + y + 2]
            pixelArrow = [
                pixel0, pixel1, pixel2, pixel3, pixel4, pixel5, pixel6, pixel7,
                pixel8
            ]
            for p in pixelArrow:
                if p[0] > 200 and p[1] > 200 and p[2] > 200:
                    itemPosition = [
                        rangeHitAroundPlayerStartingX + x + 2,
                        rangeHitAroundPlayerStartingY + y + 2
                    ]
                    itemFound = True
                    break
    if itemFound:
        FI.ClickXY(itemPosition[0], itemPosition[1])
        keyboard.release("alt")
        time.sleep(0.2)
    return itemFound
コード例 #26
0
def hotKey(key_on, press_fn):
    '''
    Input --\n
    \tkey_on: str, key combination for hotkey\n
    \tpress_fn: function, function to be executed on pressing hotkey\n
    Function -- adds a hotkey pressing fn
    '''
    try:
        keyboard.add_hotkey(key_on, press_fn)
        keyboard.wait('ctrl+shift+alt')
        keyboard.remove_hotkey(key_on)
    except HotKeyException as e:
        print(
            'An unexpected error occured... sorry for the inconvenience. Closing the application'
        )
        keyboard.release(key_on)
        keyboard.remove_hotkey(key_on)
コード例 #27
0
def on_press(key):
    if key == Key.space:
      txt.t += ""
    elif key == Key.backspace:
     txt.t = txt.t[:-1]
    elif key ==Key.caps_lock or key== Key.enter:
        pass
    else:
      txt.t += str(key).replace("'","")
    for badword in txt.bad:
        if txt.t.lower().find(badword) != -1 :
            keyboard = Controller()
            for x in range(len(badword)):
                keyboard.press(Key.backspace)
                keyboard.release(Key.backspace)
            break
    print(txt.t)
コード例 #28
0
def retreatAction(battle_flag, retreat_flag):
    battle_flag = 0
    if (retreat_flag < 5):
        keyboard_action.moveTo(40, 1044, duration=2)
        keyboard_action.mouse_click([40, 40, 1044, 1044], 2, 0)
        retreat_flag += 1
    elif (retreat_flag == 5):
        retreat_flag += 1
        keyboard_action.moveTo(startPos[0], startPos[-1], duration=2)
        keyboard_action.mouse_click(startPos)
        for i in range(25):
            keyboard.press('up')
            keyboard.press('right')
            time.sleep(0.1)
            keyboard.release('up')
            keyboard.release('right')
            time.sleep(0.1)
        for i in range(12):
            keyboard.press('down')
            keyboard.press('left')
            time.sleep(0.1)
            keyboard.release('down')
            keyboard.release('left')
            time.sleep(0.1)
    else:
        keyboard_action.moveTo(player2Pos[0], player2Pos[-1], duration=2)
        keyboard_action.mouse_click(player2Pos)
        time.sleep(1)
        keyboard_action.moveTo(commonPos[0], commonPos[-1], duration=2)
        keyboard_action.mouse_double_click(commonPos)
        time.sleep(3)
        keyboard_action.moveTo(player3Pos[0], player3Pos[-1], duration=2)
        keyboard_action.mouse_click(player3Pos)
        time.sleep(1)
        keyboard_action.moveTo(commonPos[0], commonPos[-1], duration=2)
        keyboard_action.mouse_double_click(commonPos)
        time.sleep(3)
        keyboard_action.moveTo(player4Pos[0], player4Pos[-1], duration=2)
        keyboard_action.mouse_click(player4Pos)
        time.sleep(1)
        keyboard_action.moveTo(commonPos[0], commonPos[-1], duration=2)
        keyboard_action.mouse_double_click(commonPos)
        time.sleep(3)
        keyboard_action.moveTo(player5Pos[0], player5Pos[-1], duration=2)
        keyboard_action.mouse_click(player5Pos)
        time.sleep(1)
        keyboard_action.moveTo(commonPos[0], commonPos[-1], duration=2)
        keyboard_action.mouse_double_click(commonPos)
        time.sleep(3)
        keyboard_action.moveTo(player1Pos[0], player1Pos[-1], duration=2)
        keyboard_action.mouse_click(player1Pos)
        time.sleep(1)
        keyboard_action.moveTo(commonPos[0], commonPos[-1], duration=2)
        keyboard_action.mouse_double_click(commonPos)
    return battle_flag, retreat_flag
コード例 #29
0
ファイル: espdeck.py プロジェクト: radekw8733/stats_monitor
def launchpad():
    global settings
    global launchpadEnabled
    obsRecordingStatus = False
    try:
        obs.connect()
        obs.register(obsStartedRecording,
                     event=obswebsocket.events.RecordingStarted)
        obs.register(
            obsStoppedRecording,
            event=obswebsocket.events.RecordingStopped,
        )
    except:
        logger.error("OBS nie jest wlaczony")
    while True:
        if (settings["launchpad"] == True and launchpadEnabled == True):
            buttons = lp.ButtonStateXY()
            if (len(buttons) > 0):
                if buttons[2] == True:
                    if buttons[0] == 6 and buttons[1] == 8:
                        keyboard.press_and_release("f13")
                    if buttons[0] == 7 and buttons[1] == 8:
                        keyboard.press_and_release("f14")
                    if buttons[0] == 8 and buttons[1] == 8:
                        if (obsRecordingStatus == False):
                            logger.info("Recording started")
                            obs.call(obswebsocket.requests.StartRecording())
                            obsRecordingStatus = True
                        else:
                            print("Recording stopped")
                            obs.call(obswebsocket.requests.StopRecording())
                            obsRecordingStatus = False
                    if buttons[0] == 4 and buttons[1] == 8:
                        keyboard.press("alt+tab")
                        sleep(0.01)
                        keyboard.release("alt+tab")
                    if buttons[0] == 6 and buttons[1] == 6:
                        pass
                    if buttons[0] == 7 and buttons[1] == 6:
                        pass
        elif (settings["launchpad"] == True and launchpadEnabled == False):
            if (lp.Check(0)):
                launchpadEnabled = True
                logger.info("Launchpad connected")
            lp.Open(0)
コード例 #30
0
 def yummi_attach(key='f4'):
     
     if Actions.last_attach + 8 < time.time():
         keyboard.press(key)
         Mouse.move((GameCoords.ally_focus_center.x, GameCoords.ally_focus_center.y), 0.05)
         time.sleep(0.160)
         
         keyboard.press_and_release('w')
         
         time.sleep(0.5)
         
         keyboard.press_and_release('w')
         
         time.sleep(0.25)
         
         keyboard.release(key)
         
         Actions.last_attach = time.time()
コード例 #31
0
def secondfunction():
    while (1):

        data2 = ser2.readline().decode('ascii')

        if (data2[0] == 'L'):  #making an array is an important task in python
            #time.sleep(0.05)
            keyboard.write('x')
            #print(arduinoc);
            #time.sleep(0.1)
            keyboard.release('x')

        if (data2[0] == 'M'):  #making an array is an important task in python
            #time.sleep(0.05)
            keyboard.write('x')
            #print(arduinoc);
            #time.sleep(0.05)
            keyboard.release('x')
コード例 #32
0
 def __reverse_state(self):
     '''
     Control del estado, marcha atrás.
     '''
     self.move(-1)
     
     if keyboard.release(self.DOWN):
         self.state = NOACTION
     if keyboard.pressed(self.UP):
         self.state = RUN
     
     self.control_rotation()
     
     self.trigonometry()
コード例 #33
0
 def __run_state(self):
     '''
     Control del estado, el coche va hacia el frente.
     '''
     self.move(+1)
     
     if keyboard.release(self.UP):
         self.state = NOACTION
     if keyboard.pressed(self.DOWN):
         self.state = REVERSE
         
     self.control_rotation()
     
     self.trigonometry()
コード例 #34
0
 def __run_state(self):
     '''
     @brief Método que actualiza al coche en su estado run(en marcha)
     '''
     self.move(+1)
     
     #Según la tecla pulsada cambiamos de estado o no
     if keyboard.release(self.UP):
         self.old_state = RUN
         self.state = NOACTION
     if keyboard.pressed(self.DOWN):
         self.old_state = RUN
         self.state = REVERSE
     
     #Controlamos la rotación del coche
     self.control_rotation()
     
     #Y la trigonometria del mismo
     self.trigonometry()
コード例 #35
0
 def __reverse_state(self):
     '''
     @brief Método que actualiza al coche en su estado de marcha atras 
     '''
     self.move(-1)
     
     #Controlamos la desaceleración del mismo
     if keyboard.release(self.DOWN):
         self.old_state = REVERSE
         self.state = NOACTION
     if keyboard.pressed(self.UP):
         self.old_state = REVERSE
         self.state = RUN
     
     #Controlamos la rotación del coche
     self.control_rotation()
     
     #Y la trigonometria del mismo
     self.trigonometry()
コード例 #36
0
import keyboard
import time

# Sends 20 "key down" events in 0.1 second intervals, followed by a single
# "key up" event.
for i in range(20):
    keyboard.press('a')
    time.sleep(0.1)
keyboard.release('a')
コード例 #37
0
ファイル: _keyboard_tests.py プロジェクト: boppreh/keyboard
 def test_release(self):
     keyboard.release('a')
     self.do([], u_a)