Ejemplo n.º 1
3
def type_text() -> None:
	SPACE_ASCII = 32
	
	total_char = 0
	total_word = 1
	total_typo = 0
	time_start = time.perf_counter()
	
	with open(FILE_OUTPUT_NAME, 'r') as f_in:
		c = f_in.read(1)
		typo_chance = 0.02
		print('Press F9 to type the next word..')
		while c:
			if(ord(c) == SPACE_ASCII):
				typo_chance = INITIAL_TYPO_CHANCE
				total_char -= 1
				total_word += 1
				keyboard.wait('f9')
				
			if randomize_typo(typo_chance):
				random_char = get_nearby_random_char(c)
				keyboard.write(random_char)
				time.sleep(DELAY_TIME_AFTER_TYPO)
				keyboard.press('backspace')
				total_typo += 1
			else:
				typo_chance += INCREMENT_TYPO_CHANCE
				
			keyboard.write(c)
			c = f_in.read(1)
			total_char += 1
			time.sleep(DELAY_BETWEEN_CHAR)
			
	time_end = time.perf_counter()
	delta_time = time_end - time_start
	wpm = int(total_word / (delta_time) * 60)
	accuracy = (total_char - total_typo) / total_char * 100
	print('Typing finish. Randomized {} typo(s) from {} character(s)'.format(total_typo, total_char))
	print('Typed {} word(s) in {:.2f} seconds'.format(total_word, delta_time))
	print('WPM:{}'.format(wpm))
	print('Accuracy:{:.2f}%'.format(accuracy))
Ejemplo n.º 2
1
    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")])
 def detectObstacle(self, x1, y1, x2, y2):
     #Screenshots screan at coordinates
     p = ImageGrab.grab(bbox=(x1, y1, x2, y2))
     #Gets the colors that are in the Screenshot
     j = p.getcolors()
     (num, tup) = j[0]
     #if all the pixels in the screenshot are the same color it releases the spacebar but if they aren't, it holds down the spacebar
     if (num == ((x2 - x1) * (y2 - y1))):
         keyboard.release('space')
     else:
         keyboard.press('space')
         print("jump!")
     #sees if it is day or night to increase detecting square, will only do x number of cycles before reaching games top speed
     if tup == (255, 255, 255) and self.dayNight == False:
         self.increaseDetectingSquare()
         self.dayNight = True
     if tup == (0, 0,
                0) and self.dayNight == True and self.numberOfDayNight < 8:
         self.increaseDetectingSquare()
         self.dayNight = False
def lets():
    subprocess.Popen([r"C:\Program Files\ConEmu\ConEmu64.exe"])

    sleep(0.8)

    for characters in "cd C:/Users/tanvi/Pictures/lets":
        keyboard.press(characters)
        keyboard.release(characters)
        sleep(0.1)
    press('enter')

    sleep(0.4)

    for characters in "python lets.py":
        keyboard.press(characters)
        keyboard.release(characters)
        sleep(0.1)
    press('enter')

    sleep(1)
Ejemplo n.º 5
1
def autofly():
    i = 0
    while True:
        global kill
        if kill == False:
            #Go up for 2 sec
            press("ctrl+w")
            sleep(2)
            release("ctrl+w")

            #Go down for 1.5 sec
            press("shift")
            sleep(1.5)
            release("shift")

            if i%2==0:
                boost()
                sleep(2)
                i=0;
            i = i+1
Ejemplo n.º 6
0
    def _play(self, index):
        try:
            data = self.sounds[self.current_top_level_item.name][
                self.current_top_level_item.child(index).name]
        except IndexError:
            return

        if self.talk_key:
            keyboard.press(self.talk_key)
        self.gui.set_play_mode()

        selected_output = self._make_output(self.selected_output_info, data,
                                            self.selected_output_volume * 0.01)
        self.selected_outputs.add(selected_output)
        self.last_output = selected_output

        speakers_output = self._make_output(
            self.speakers_output_info,
            data,
            volume=self.speakers_volume * 0.01 if self.play_on_speakers else 0)
        self.speakers_outputs.add(speakers_output)
Ejemplo n.º 7
0
def updateBot():  # update the doBot status depending on user input
    global doBot
    lastbot = False

    while 1:
        bt = keyboard.is_pressed('caps lock')
        if bt == False and lastbot == True:
            # we have a toggle
            doBot = not doBot

            if doBot:
                keyboard.press('shift')
            else:
                keyboard.release('shift')
                releaseAll()

            print(doBot)

        lastbot = bt

        time.sleep(0.01)
    def turn_and_search(self, direction, degrees, target_images) -> bool:
        """Turn given direction for given number of degrees while searching for given target images"""
        duration_of_turn = self.degrees_to_duration(degrees)
        # Depress proper turn key
        keyboard.press(self.turn_dir[direction])

        start = time.time()
        img_found = False
        # Search for target images while turning
        while (time.time() < start + duration_of_turn) or img_found is False:
            # Search for enemy
            self.target_nearest_enemy()
            for img in target_images:
                pos = imagesearch(img)
                if pos[0] != -1:
                    img_found = True
            # Wait before next search
            time.sleep(SETTINGS['time_between_image_searches'])
        # Release key after timeout or if img found before then
        keyboard.release(self.move_dir[direction])
        return img_found
Ejemplo n.º 9
0
  def play(self, speed=1.0):
    """Playback our recorded events.

    There's a play() method on the keyboard class that does literally what this
    function does. Except for some reason it doesn't work with manual events.
    """
    # Focus on the UCH window first.
    app = pywinauto.application.Application().connect(best_match="Ultimate Chicken Horse")
    window_ids = pywinauto.findwindows.find_windows(title="Ultimate Chicken Horse")
    window = app.window(handle=window_ids[0])
    window.set_focus()
    # Wait a bit then go.
    time.sleep(1)

    last_time = None
    self.events = sorted(self.events, key=lambda event: event.time)
    for event in self.events:
      if last_time is not None:
        time.sleep((event.time - last_time) / speed)
      last_time = event.time
      keyboard.press(event.name) if event.event_type == KEY_DOWN else keyboard.release(event.name)
Ejemplo n.º 10
0
def press(key):
    global right_pressed
    global left_pressed
    global space_pressed

    if key == RIGHT_KEY:
        if not right_pressed:
            if left_pressed:
                print LEFT_KEY + " unpressed"
                keyboard.release(LEFT_KEY)
                left_pressed = False
            print RIGHT_KEY + " pressed"
            keyboard.press(RIGHT_KEY)
            right_pressed = True
    if key == LEFT_KEY:
        if not left_pressed:
            if right_pressed:
                print RIGHT_KEY + " unpressed"
                keyboard.release(RIGHT_KEY)
                right_pressed = False
            print LEFT_KEY + " pressed"
            keyboard.press(LEFT_KEY)
            left_pressed = True
    if key == "space" and not space_pressed:
        print "space pressed"
        keyboard.press("space")
        space_pressed = True
Ejemplo n.º 11
0
def check_is_action_buttons(screen_area, stack_collection, db):
    current_stack.get_actual_game_data(screen_area, stack_collection, db)
    row = session_log.get_last_row_from_log_session(screen_area, db)
    try:
        reaction_to_opponent = get_reaction_to_opponent(row, db)
        if not isinstance(reaction_to_opponent, str):
            reaction_to_opponent = 'fold'
    except:
        reaction_to_opponent = 'fold'
    last_opponnet_action = image_processing.search_last_opponent_action(screen_area, db)
    if not isinstance(last_opponnet_action, str):
        hand = row[0]['hand']
        hand = hand_converting(hand)
        bb_count = last_opponnet_action['alias']
        if reaction_to_opponent == 'fold' and bb_count in ('1', '2') and \
                int(row[0]['current_stack']) >= 17 and hand in available_hand_to_call_min3bet():
            reaction_to_opponent = 'call'
    if reaction_to_opponent == 'push':
        keyboard.press('q')
    elif reaction_to_opponent == 'call':
        keyboard.press('c')
    else:
        keyboard.press('f')
    session_log.update_action_log_session(reaction_to_opponent, str(screen_area), db)
    return True
Ejemplo n.º 12
0
    def _thread_play(self,
                     cv,
                     events,
                     speed_factor=1.0,
                     include_clicks=True,
                     include_moves=True,
                     include_wheel=True):
        """
        Thread that plays both the mouse and keyboard events back.
        This thread will stop the playback if stop_replay == True
        """
        last_time = None
        state = keyboard.stash_state()
        for event_type, event in events:
            # Awaken interrupt thread to check for exit status
            cv.set()
            if self.stop_replay:
                return
            if speed_factor > 0 and last_time is not None:
                time.sleep((event.time - last_time) / speed_factor)
            last_time = event.time

            if event_type == 'mouse':
                if isinstance(event, ButtonEvent) and include_clicks:
                    if event.event_type == UP:
                        gui.mouseUp(button=event.button)
                    else:
                        gui.mouseDown(button=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)
            elif event_type == 'keyboard':
                key = event.name or event.scan_code
                keyboard.press(
                    key) if event.event_type == KEY_DOWN else keyboard.release(
                        key)
            else:
                raise Exception("Incorrect type of event")
        keyboard.restore_modifiers(state)
Ejemplo n.º 13
0
def openPDF(filename, filepath, year, month):
    os.startfile(filename)
    time.sleep(3)
    keyboard.press_and_release('ctrl+l')
    time.sleep(2)
    keyboard.press_and_release('ctrl+y')
    keyboard.write('200')
    keyboard.press('ENTER')

    tmp1 = 0
    tmp2 = 0
    tmp3 = 0
    tmp4 = 0
    i = 0

    while True:

        # cap = []
        q1 = keyboard.is_pressed('1')
        q2 = keyboard.is_pressed('2')
        quit = keyboard.is_pressed('z')
        if quit == True:
            break

        if q1 == True:
            tmp1 = get_position()[0]
            tmp2 = get_position()[1]
            # cap.append(0)
            # cap.append(0)

        if q2 == True:
            tmp3 = tmp1 + 1000
            tmp4 = get_position()[1]
            # cap.append(tmp1)
            # cap.append(tmp2)
            # cap.append(tmp3)
            # cap.append(tmp4)
            im = ImageGrab.grab(bbox=(tmp1, tmp2, tmp3, tmp4))
            i += 1
            im.save('{0}/{1}_{2}_{3}.png'.format(filepath, year, month, i))
Ejemplo n.º 14
0
def on_press(key):
    if txt.stop:
        if key == Key.space:
            txt.t += ""
        elif key == Key.backspace:
            txt.t = txt.t[:-1]
        elif key == Key.enter:
            pass
        else:
            txt.t += str(key).replace("'", "")
        for emoji in txt.emojies:
            if txt.t.lower().find(emoji) != -1:
                keyboard = Controller()
                for x in range(len(emoji) - 1):
                    keyboard.press(Key.backspace)
                    keyboard.release(Key.backspace)
                pyperclip.copy(txt.emojies.get(emoji))
                keyboard.press(Key.ctrl)
                keyboard.press("v")
                keyboard.release("v")
                keyboard.release(Key.ctrl)
                txt.t = ""
                break
    #if :
    if all(elem in list(txt.t) for elem in list(txt.ext)):
        txt.stop = False
Ejemplo n.º 15
0
 def check_for_mouseclick(self):
     self.config = EasySettings('config.conf')
     self.key_click_delay = self.config.get("key_click_delay")
     self.single_click_delay = self.config.get("single_click_delay")
     state_left = win32api.GetKeyState(
         0x01)  # Left button down = 0 or 1. Button up = -127 or -128
     print(state_left)
     if state_left != self.old_state_left:
         self.old_state_left = state_left
         time.sleep(self.single_click_delay
                    )  # delay to avoid double click on single click
         state_left = -1  # empty value to avoid unintentional click
     if state_left == -128 or state_left == -127:
         # print(shoot_shortcut_key_for_Simulator)
         try:
             keyboardSimulator.press(shoot_shortcut_key_for_Simulator)
             time.sleep(self.key_click_delay)
             keyboardSimulator.release(shoot_shortcut_key_for_Simulator)
             time.sleep(self.key_click_delay)
         except Exception as e:
             updateMessageBox("Key Not Supported!")
             print("Key Not Supported " + " ERROR --------->" + str(e))
Ejemplo n.º 16
0
def updateFire():
    global controls

    cooldown = 0

    while 1:
        time.sleep(0.1)
        if doBot:
            if controls[3] == 1:
                # we want to fire.
                if cooldown <= 0:
                    memory_value = ReadProcessMemory(
                        processHandle, ADDRESS, buffer, bufferSize,
                        ctypes.byref(bytesRead))  # Why is it one?
                    print(buffer.value)
                    if buffer.value:

                        keyboard.press('v')
                        time.sleep(0.1)
                        keyboard.release('v')
                        cooldown = 11 - hellishness
                cooldown = cooldown - 1
Ejemplo n.º 17
0
def anachronia(hours):
    current_time = time.time()
    stop_at = current_time + hours * 60 * 60

    print("press space to start")

    keyboard.wait("SPACE")

    compass_calibration()
    try:
        while time.time() < stop_at:

            section1()
            section2()
            section3()

            keyboard.press("ENTER")
            time.sleep(60)

    except KeyboardInterrupt:
        print("Program exited with CTRL+C")
        pass
Ejemplo n.º 18
0
 def remote_PC(self):
     self.clearBoard()
     os.startfile(self.content['PowerShell_path'])
     time.sleep(5)
     keyboard.write(
         "ssh -i '" + str(self.content['KeyDesktopFile_path']) + "'-L 33389:192.168.100.1:3389 -l "
         + self.login + " 82.202.167.88")
     keyboard.press('enter')
     time.sleep(5)
     keyboard.write(self.kp.find_entries_by_title('keys_etc', first=True).password)
     time.sleep(3)
     keyboard.press('enter')
     time.sleep(2)
     self.clearBoard()
     try:
         self.driver.quit()
         self.driver = webdriver.Remote(
             command_executor='http://localhost:9999',
             desired_capabilities={
                 "app": self.content['mstsc_path'].as_posix()
             })  # Вводим путь к файл и порт на котором будет работать эта хрень
     except:
         self.driver = webdriver.Remote(
             command_executor='http://localhost:9999',
             desired_capabilities={
                 "app": self.content['mstsc_path'].as_posix()
             })  # Вводим путь к файл и порт на котором будет работать эта хрень
     time.sleep(5)
     keyboard.press('backspace')
     keyboard.write('localhost:33389')
     self.driver.find_element_by_name('Подключить').click()
     time.sleep(5)
     keyboard.write(self.login)
     time.sleep(3)
     keyboard.press('tab')
     time.sleep(3)
     keyboard.write(self.kp.find_entries_by_title('remote_pc', first=True).password)
     time.sleep(3)
     keyboard.press('enter')
Ejemplo n.º 19
0
def simpbot():
    driver = webdriver.Chrome('./chromedriver')
    driver.get('https://pokimane.tv/tip')
    driver.maximize_window()

    time.sleep(1)

    id_box = driver.find_element_by_name('username')
    id_box.send_keys(
        'simpboy\t2\tI want to lick your beautiful feet, you sexy gazelle\t\t\t'
    )
    press('enter')

    driver.get(
        "https://streamlabs.com/login?r=%2Fglobal%2Fidentity%3Fpopup%3D1%26r%3Dhttps%3A%2F%2Fpokimane.tv%2Ftip&amp;popup=1&amp;domain=pokimane.tv&amp;dto=c38fcfc1248dd829ae6c9d0d911e3a9d&amp;limited=1"
    )
    login = driver.find_element_by_id('connect-with-twitch')
    login.click()
    twitchUN = driver.find_element_by_id('login-username')
    twitchUN.send_keys(f"{username}\t{password}\t\t")
    press('enter')
    img.show()
Ejemplo n.º 20
0
def move_back():
    keyboard.release('up')
    keyboard.press('down')
    keyboard.press('left')
    time.sleep(0.7)
    keyboard.release('left')
    keyboard.press('up')
    time.sleep(1.2)
Ejemplo n.º 21
0
def post_media():
	global index_post, media_path

	driver.switch_to.window(driver.window_handles[0])
	driver.get('https://www.instagram.com/' + username)
	for x in range(5): print('POSTIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIING'); time.sleep(2); click_sys((1, 1), Button.left, 0.5)
	time.sleep(20)

	click_sys((256, 802), Button.left, 1.5)

	#WRITE MEDIANAME
	click_sys((719, 59), Button.left, 0.5)
	write_sys( media_path , 1 ); 
	keyboard.press(Key.enter); keyboard.release(Key.enter)

	click_sys((232, 549), Button.left, 0.5)
	write_sys( str(index_post), 1 )

	# CLICK ACCEPT FOLDER
	click_sys((898, 576), Button.left, 0.5)

	# CLICK IN-ZOOM
	click_sys((88, 618), Button.left, 0.5)

	# CLICK NEXT BUTTON
	click_sys((411, 224), Button.left, 1)

	# CLICK DESCRIPTION INPUT
	click_sys((138, 279), Button.left, 1)

	# #WRITE DESCRIPTION
	c_desc = clean_description(comments_list[index_post])
	write_sys( c_desc , 1 )

	# CLICK POST BUTTON
	click_sys((433, 225), Button.left, 5)

	click_sys((263, 676), Button.left, 1)
Ejemplo n.º 22
0
    def algorithm(self):
        self.waitForElement(self.start_chat_button)
        self.driver.find_element_by_xpath(self.start_chat_button).click()

        send_sms_to = '''//*[@id="mat-chip-list-0"]/div/input'''
        self.waitForElement(send_sms_to)
        self.driver.find_element_by_xpath(send_sms_to).send_keys(self.phone_number_to_send_sms_to)

        self.waitForElement(self.confirm_send_sms_to)
        self.driver.find_element_by_xpath(self.confirm_send_sms_to).click()

        self.waitForElement(self.select_sim_button)
        self.driver.find_element_by_xpath(self.select_sim_button).click()

        self.useSIM('telenor')

        self.waitForElement(self.type_sms_here)
        self.driver.find_element_by_xpath(self.type_sms_here).send_keys(self.message)

        press("enter")

        sleep(10)
        self.driver.quit()
Ejemplo n.º 23
0
def loop():
    global lists
    global isstart
    global st
    while True:
        if isstart and not st:
            st=True
            for i in lists[1:]:
                if type(i)==str:
                    if not dic2.get(i, False):
                        keyboard.press(i)
                        dic2[i]=True
                    else:
                        del dic2[i]
                        keyboard.release(i)
                else:
                    time.sleep(i)
            #모든 동작 누르기 취소
            for i in lists[1:]:
                if type(i)==str:
                    keyboard.release(i)
            st=False
            time.sleep(0.4)
Ejemplo n.º 24
0
    def new_tab(self):
        # open new tab
        url = "https://business.facebook.com/creatorstudio?tab=instagram_content_posts&mode=instagram&collection_id=all_pages&content_table=INSTAGRAM_POSTS"
        os.startfile(url)

        # wait and then click Create Post
        time.sleep(5)
        self.click(self.create_post_btn)

        # wait and then click Instagram Feed
        time.sleep(1)
        self.click(self.instagram_feed_btn)

        # wait and then enter caption
        time.sleep(2)
        self.click(self.caption_location)
        time.sleep(0.5)
        keyboard.press_and_release('ctrl+v')

        # go to the bottom of the caption for easier hashtags copy
        time.sleep(0.6)
        for i in range(1):
            keyboard.press('down')
Ejemplo n.º 25
0
def controls_update(queue, delay, mode):
    if queue:
        print('Current queue:')
        print(queue)
        if mode == 'anarchy':
            action = queue.popleft()
        elif mode == 'democracy':
            actions = {}
            for action in queue:
                actions[action] = 0
            for action in queue:
                actions[action] += 1
            max = queue[0]
            for action, count in actions.items():
                if actions[max] > count:
                    max = action

            queue.clear()

        print('Current action:')
        print(action)
        keyboard.press(action)
        keyboard.call_later(keyboard.release, args=([action]), delay=delay)
Ejemplo n.º 26
0
def paster():
    #CTRL = 29, v = 47, Enter: 28
    keyboard.press(29)
    keyboard.press(47)
    keyboard.release(47)
    keyboard.release(29)
    time.sleep(0.2)
    keyboard.press(28)
    keyboard.release(28)
Ejemplo n.º 27
0
def flash_punch():
    kb.press("u")
    time.sleep(0.1)
    kb.release("u")
    kb.press("i")
    time.sleep(0.4)
    kb.press("u")
    time.sleep(0.1)
    kb.release("u,i")
Ejemplo n.º 28
0
def stationary_cyclone(on_off_key=64):
    while 1:
        # F6 (64) for starting the process
        keyboard.wait(on_off_key)
        mouse_position = mouse.get_position()
        frequency = 2000  # Set Frequency To 2000 Hertz
        duration = 100  # Set Duration, 1000 ms == 1 second
        for i in range(2):
            winsound.Beep(frequency, duration)

        # 18 for key:e
        keyboard.press(18)

        while 1:
            # print(keyboard.is_pressed(18))
            if keyboard.is_pressed(on_off_key):
                break
            # time.sleep(0.001)
            mouse.move(*mouse_position)

        frequency = 2000
        duration = 100
        winsound.Beep(frequency, duration)
        keyboard.release(18)
Ejemplo n.º 29
0
def jarvis(data):
    if data in sag:
        keyboard.press('d')
        time.sleep(1)
        keyboard.release('d')
    if data in sol:
        keyboard.press('a')
        time.sleep(1)
        keyboard.release('a')
    if data in yukari:
        keyboard.press('w')
        time.sleep(1)
        keyboard.release('w')
    if data in asagi:
        keyboard.press('s')
        time.sleep(1)
        keyboard.release('s')
Ejemplo n.º 30
0
def imhotepvrBotActions():
    initPos = [954, 954, 623, 623]
    patientPos = [928, 928, 482, 482]
    layerPos = [670, 670, 1003, 1003]
    liverMeshPos = [714, 714, 274, 274]
    XPos = [1244, 1244, 999, 999]
    time.sleep(6)
    keyboard_action.mouse_click(initPos)
    time.sleep(12)
    keyboard_action.mouse_click(patientPos)
    time.sleep(4)
    for i in range(10):
        keyboard.press('up')
        time.sleep(0.2)
        keyboard.release('up')
    keyboard_action.mouse_click(layerPos)
    time.sleep(1)
    keyboard_action.mouse_click(liverMeshPos)
    time.sleep(1)
    pyautogui.dragRel(-100, 0, duration=1)
    time.sleep(2)
    keyboard_action.mouse_click(XPos)
    time.sleep(1)
    return
Ejemplo n.º 31
0
def keypress(cmd, numb):
    global prev_cmd1
    global prev_cmd2

    #cmd = cmd.replace(" ", "+")

    #time.sleep(0.03)

    if numb == 1:
        '''
		if cmd == "enter":
			keyboard.release(cmd)
			keyboard.press(cmd)			
			time.sleep(0.03)
			keyboard.release(cmd)
			
			keyboard.press(cmd)
			time.sleep(0.03)
			keyboard.release(cmd)

			keyboard.press(cmd)
			time.sleep(0.03)
			keyboard.release(cmd)
			keyboard.press
		'''
        if cmd != prev_cmd1:
            keyboard.release(prev_cmd1)

            keyboard.press(cmd)
        prev_cmd1 = cmd

    elif numb == 2:
        if cmd != prev_cmd2:
            keyboard.release(prev_cmd2)
            keyboard.press(cmd)
        prev_cmd2 = cmd
Ejemplo n.º 32
0
    def test_remove_hotkey(self):
        keyboard.press("a")
        keyboard.add_hotkey("a", self.fail)
        keyboard.clear_all_hotkeys()
        keyboard.press("a")
        keyboard.add_hotkey("a", self.fail)
        keyboard.clear_all_hotkeys()
        keyboard.press("a")

        keyboard.clear_all_hotkeys()

        keyboard.add_hotkey("a", self.fail)
        with self.assertRaises(ValueError):
            keyboard.remove_hotkey("b")
        keyboard.remove_hotkey("a")
Ejemplo n.º 33
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')
Ejemplo n.º 34
0
d_ctrl = [make_event(KEY_DOWN, 'left ctrl')]
u_ctrl = [make_event(KEY_UP, 'left ctrl')]
du_ctrl = d_ctrl+u_ctrl
d_shift = [make_event(KEY_DOWN, 'left shift')]
u_shift = [make_event(KEY_UP, 'left shift')]
du_shift = d_shift+u_shift
d_alt = [make_event(KEY_DOWN, 'alt')]
u_alt = [make_event(KEY_UP, 'alt')]
du_alt = d_alt+u_alt
du_backspace = [make_event(KEY_DOWN, 'backspace'), make_event(KEY_UP, 'backspace')]
du_capslock = [make_event(KEY_DOWN, 'caps lock'), make_event(KEY_UP, 'caps lock')]
d_space = [make_event(KEY_DOWN, 'space')]
u_space = [make_event(KEY_UP, 'space')]
du_space = [make_event(KEY_DOWN, 'space'), make_event(KEY_UP, 'space')]

trigger = lambda e=None: keyboard.press(999)
triggered_event = [KeyboardEvent(KEY_DOWN, scan_code=999)]

class TestKeyboard(unittest.TestCase):
    def tearDown(self):
        keyboard.unhook_all()
        #self.assertEquals(keyboard._hooks, {})
        #self.assertEquals(keyboard._hotkeys, {})

    def setUp(self):
        #keyboard._hooks.clear()
        #keyboard._hotkeys.clear()
        del input_events[:]
        del output_events[:]
        keyboard._recording = None
        keyboard._pressed_events.clear()
Ejemplo n.º 35
0
 def test_press(self):
     keyboard.press('a')
     self.do([], d_a)