Exemplo n.º 1
0
    def test_send(self):
        keyboard.send("shift", True, False)
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "shift")])

        keyboard.send("a")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "a"), (KEY_UP, "a")])

        keyboard.send("a, b")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "a"), (KEY_UP, "a"), (KEY_DOWN, "b"), (KEY_UP, "b")])

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

        self.press("a")
        keyboard.write("a", restore_state_after=False, delay=0.001)
        # TODO: two KEY_UP 'a' because the tests are not clearing the pressed
        # keys correctly, it's not a bug in the keyboard module itself.
        self.assertEqual(self.flush_events(), [(KEY_UP, "a"), (KEY_UP, "a"), (KEY_DOWN, "a"), (KEY_UP, "a")])

        shift_scan_code = scan_codes_by_name["shift"]

        keyboard.send(shift_scan_code, True, False)
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "shift")])
        keyboard.send([[shift_scan_code]], True, False)
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "shift")])
        keyboard.send([["shift"]], True, False)
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "shift")])
Exemplo n.º 2
0
 def write_word(self, word):
     '''
     Apaga a palavra que esta sendo digitada e escreve a palavra recebida
     :param word: Palavra que ira ser escrita
     :return: None
     '''
     keyboard.press_and_release("ctrl + backspace")
     keyboard.write(word)
     keyboard.press_and_release("space")
Exemplo n.º 3
0
def makeNice():
    text = clipboard.paste()
    lenght = len(text)
    output = []
    for i in range(lenght):
        if (i % 2) == 0:
            output.append(text[i].upper())
        else:
            output.append(text[i])
            
    keyboard.write("".join(output))
Exemplo n.º 4
0
    def button_press(self, sub_exp):
        """
        if sub_exp not in {"<-", "clear"}:
            expression = self._view.displayText() + sub_exp
            self._view.setDisplayText(expression)
        """

        print("Clicked ", sub_exp)
        X = ""
        Y = ""
        X1 = ""
        Y1 = ""
        with open('mouse_log.txt', 'r') as f:

            lines = f.read().splitlines()
            last_line = lines[-2]
            new_line = lines[-1]

        i = 0
        while (last_line[i] != '('):
            i = i + 1
        i = i + 1
        while (last_line[i] != ','):
            X = X + last_line[i]
            i = i + 1
        i = i + 1

        while (last_line[i] != ')'):
            Y = Y + last_line[i]
            i = i + 1
        print(X, Y)

        pyautogui.click(int(X), int(Y))
        if sub_exp not in {"<-", "clear", "space"}:
            keyboard.write(sub_exp)
        elif sub_exp == "<-":
            keyboard.press_and_release('backspace')
        elif sub_exp == "space":
            keyboard.press_and_release('space')
        pyautogui.click(int(X) + 10, int(Y))

        i = 0
        while (new_line[i] != '('):
            i = i + 1
        i = i + 1
        while (new_line[i] != ','):
            X1 = X1 + new_line[i]
            i = i + 1
        i = i + 1

        while (new_line[i] != ')'):
            Y1 = Y1 + new_line[i]
            i = i + 1
        pyautogui.moveTo(int(X1), int(Y1))
Exemplo n.º 5
0
    def heal_health(self, percent, spell, time):
        print('heal')
        life = self.get_health()

        if (life):
            while life < percent:
                keyboard.write(spell)
                #time.sleep(time)
                keyboard.press('enter')
                #time.sleep(time)
                life = self.get_health()
Exemplo n.º 6
0
    def onPressHotkey(self, event) -> None:
        self.bengali = parse(self.current)  #parsed value will be stored in

        # fire backspace to delete previous word
        # then place the bengali word followed by triggered key
        replace: str = '\b' * (len(self.current) +
                               1) + self.bengali + CODE_DICT[event.name]

        self.previous = self.current  # store the current value to previous for `smart backspace`
        self.current = ""
        write(replace)  # write the string
 def wordFill():
     lenLast = len(lastWord)
     selWord = currentList[0]
     selWord = selWord[lenLast:]
     if len(selWord) < 1:
         wordPrint = selWord
     else:
         wordPrint = selWord + " "
         keyboard.write(wordPrint,
                        delay=0,
                        restore_state_after=True,
                        exact=None)
Exemplo n.º 8
0
def enterMeeting():
    keyboard.send('win+d') #Go to desktop
    time.sleep(1)
    app = Application(backend='uia').start(f'{CiscoDirectory}') #Open Cisco Webex
    app = Application(backend='uia').connect(path=f'{CiscoDirectory}')
    time.sleep(5)
    app.Pane.Edit.click_input() #Click the code box
    keyboard.send('ctrl+a')
    keyboard.write(getCode()) #Write down the code
    keyboard.send('enter')
    time.sleep(10)
    keyboard.send('enter')
Exemplo n.º 9
0
def submitFunction():
    global clipboard
    button.place_forget()
    countDown()

    # Click into window
    x, y = pyautogui.position()
    pyautogui.click(x, y)

    # "Paste"
    keyboard.write(clipboard)
    ready.set(1)
Exemplo n.º 10
0
    def select_champ(champ_name):
        Client.ele_lobby_champ_search.click()
        time.sleep(3)

        keyboard.write(champ_name, 0.1)
        time.sleep(3)

        Client.ele_lobby_first_champ.click()
        time.sleep(3)

        Client.ele_lobby_lock_in.click()
        time.sleep(1)
def start():
    import socket
    import time
    import sys
    import os
    import re
    import smtplib
    import keyboard
    import pyautogui
    s = socket.socket()
    s.connect(('192.168.3.7', 5050))  # тут ip
    while True:

        text = s.recv(1024).decode()
        print(text)
        if text == 'realtime':
            ccc = smtplib.SMTP('smtp.mail.ru', 587)
            ccc.starttls()
            ccc.login('*****@*****.**', 'Fastplaypro')
            ccc.sendmail('*****@*****.**',
                         '*****@*****.**', time.ctime())
            ccc.quit()
            start()
        elif re.search(r'\bprint\b', text):
            keyboard.write(text[8:], int(text[6:7]))
            start()
            os.execl(sys.executable, sys.executable, *sys.argv)
            start()
        elif re.search(r'\bclick\b', text):
            cor = int(text[6:8]), (text[10:12])
            print(cor)
            pyautogui.click(cor)
            start()
            os.execl(sys.executable, sys.executable, *sys.argv)
        elif text == 'skip':
            pyautogui.click(1871, 1003)
            start()
        elif text == 'pouse':
            pyautogui.click(500, 500)
            start()
        elif text == 'quit':
            os.system('shutdown -s -t 5')
            start()
        elif text == 'skip2':
            pyautogui.click(1221, 964)
            start()
        elif re.search(r'\bkey\b', text):
            keyboard.press_and_release(str(text[4:]))
            start()
        else:
            start()

        os.execl(sys.executable, sys.executable, *sys.argv)
Exemplo n.º 12
0
def shopItem(config, data):

    #open shop
    keyboard.press_and_release(config['OPEN_BUY_MENU'])
    time.sleep(0.1)
    keyboard.press_and_release("ctrl+L")
    time.sleep(0.1)
    keyboard.write(data)
    time.sleep(0.2)
    keyboard.press_and_release("enter, enter")
    time.sleep(0.1)
    keyboard.press_and_release(config['OPEN_BUY_MENU'])
Exemplo n.º 13
0
def informationInput():
    keyboard.write(PRODUCT_PART_NUMBER)
    pyautogui.press("tab")
    keyboard.write(PRODUCT_SERIAL_PREFIX)
    pyautogui.press("tab")
    keyboard.write(PRODUCT_MANUFACTURING_DATE)
    pyautogui.press("tab")
    keyboard.write(MANUFACTURER)
    pyautogui.press("tab")
    pyautogui.press("tab")
    pyautogui.press("tab")
    keyboard.write(PRODUCT_DESCRIPTION)
Exemplo n.º 14
0
def layout_tags(event):
    c = None
    if event.name in BASIC_LATIN:
        c = chr(ord(event.name) + 0xE0000)
    elif event.name == "space":
        c = chr(0xE0020)
    elif event.name == "delete":  # delete becomes TAG CANCEL (corresponds)
        c = chr(0xE007F)
    elif event.name == "insert":  # insert becomes LANGUAGE TAG (deprecated)
        c = chr(0xE0001)
    if c:
        keyboard.write(c)
Exemplo n.º 15
0
def ISimulateThingY(Location):
    file1 = open(Location,"r+")
    SaveContent = file1.read()
    file1.seek(0)
    SaveContent = SaveContent.decode('utf-8')
    keyboard.write('        \n')
    keyboard.write(SaveContent)
   # for element in SaveContent:
   #     keyboard.press("%s" %element)
   #     keyboard.release("%s" %element)
   # time.sleep(1)
    print "\nFile has finished Typing\n\n"
Exemplo n.º 16
0
    def find_password(self):
        with open('brute_param.json') as json_file:
            param = json.load(json_file)

        current = browser.get('safari')
        current.open(self.web_address)

        time.sleep(1)
        flag = 0

        for i in range(0, 10):
            if flag == 1:
                break
            for j in range(0, 10):
                if flag == 1:
                    break
                for k in range(0, 10):
                    if flag == 1:
                        break

                    password = str(i) + str(j) + str(k)

                    auto.press('tab')
                    keyboard.write(param['username'])

                    auto.press('tab')
                    keyboard.write(password)

                    auto.press('tab')
                    auto.press('enter')

                    auto.press('tab')
                    auto.hotkey(
                        'command', 'q'
                    )  #===> NOTE: on "qwerty" keyboards, replace "q" by "a"
                    auto.hotkey('command', 'c')

                    webpage_reply = xerox.paste()

                    print(password)
                    print(webpage_reply)
                    print()

                    if "Incorrect" in webpage_reply:
                        for n in range(
                                0, 8
                        ):  #===> NOTE: the number of necessary 'tab' can change
                            auto.press('tab')
                        auto.press('enter')
                        xerox.copy("stop")
                    else:
                        flag = 1
 def _inner():
     for e in re.findall('\{[^\}]+\}|[^\{\}]+', text):
         if e[0] == '{':
             e = e[1:-1]
             if e.isnumeric():
                 e = int(e)
             else:
                 e = CMAP.get(e.lower(), e)
             # print(f'Key: {e}')
             keyboard.send(e)
         else:
             # print(f'Text: {e}')
             keyboard.write(e)
Exemplo n.º 18
0
def save():
    keyboard.press_and_release('alt+tab')
    time.sleep(0.3)
    keyboard.press_and_release('ctrl+s')
    time.sleep(0.3)
    keyboard.write('board.html')
    time.sleep(0.3)
    keyboard.press_and_release('enter')
    time.sleep(0.3)
    keyboard.press_and_release('left')
    time.sleep(0.3)
    keyboard.press_and_release('enter')
    time.sleep(0.3)
Exemplo n.º 19
0
def exeFind(tokens):
    """Finds text on the page."""

    if len(tokens) > 0 and tokens[0] == "PHRASE":
        send_message(encode_message([KeyboardMessage('/')]))
        time.sleep(0.5)
        keyboard.write(' '.join(tokens[1:]))
        time.sleep(0.25)
        keyboard.press_and_release('enter')
    else:
        gui.showError("Unrecognized\nFind sequence")

    time.sleep(1)
Exemplo n.º 20
0
 def smartBackspace(self, event) -> None:
     if self.current != "":  # for normal backspace
         self.current = self.current[:-1]  # omit the last char
     # ** smart Backspace model **
     # ---------------------------
     # if `shift` is pressed and `bengali` string is not empty
     elif is_pressed('shift') and self.bengali != "":
         # fire backspace to delete previous word
         # and the place the `previous`
         replace: str = '\b' * (len(self.bengali)) + self.previous
         # now set the the current to previous
         self.current = self.previous
         write(replace)  # write the string
Exemplo n.º 21
0
def allcommand(time_wait, time_wait_items, commands):
    print(
        "------------------------AUTO-COMMAND Scum V1------------------------\n"
    )
    print("Démarrage dans", time_wait, "secondes...")
    time.sleep(float(time_wait))
    print("----------------Démarrage------------------")
    for value in commands:
        print("give de l'item :", value)
        keyboard.write(value)
        time.sleep(float(time_wait_items))
        keyboard.press_and_release('enter')
    print("------------------FIN---------------------")
Exemplo n.º 22
0
def reprow():
    """Подстановка данных в буфер обмена"""
    global RowCount
    global Values
    global Cycles
    if RowCount < Cycles:
        if Values[RowCount] != "0":
            keyboard.write(Values[RowCount])
        else:
            keyboard.write("")
        RowCount += 1
    else:
        return
Exemplo n.º 23
0
 def speechin():
      
    r = sr.Recognizer()                 # initialize recognizer
    with sr.Microphone() as source:     # mention source it will be either Microphone or audio files.
     print("Speak Anything :")
     audio = r.listen(source)        # listen to the source
    try:
     text = r.recognize_google(audio)    # use recognizer to convert our audio into text part.
     print("You said : {}".format(text))
    except:
     print("Sorry could not recognize your voice")    # In case of voice not recognized 
    keyboard.write(text)
    keyboard.press_and_release("enter")
Exemplo n.º 24
0
def keyPressed(key):
    # Error handler
    try:
        # pressNum is a random number from 1-5
        pressNum = r.randint(1, 5)
        # if input key is pressed
        if keyboard.is_pressed(key):
            # Press the input key pressNum amount of times
            for i in range(0, pressNum):
                keyboard.write(key)
    # Catches error by passing
    except:
        pass
Exemplo n.º 25
0
def send_message(event):
    time = grab_image(event)
    if config["use_mode"] == "no_enter":
        keyboard.send('enter')
        keyboard.write(time)
        keyboard.call_later(lambda: keyboard.send('enter'), (), 0.01)
        # keyboard.tap(Key.enter)
        # keyboard.type(time)
        # sleeper.sleep(0.03)
        # keyboard.tap(Key.enter)
    # keyboard.call_later(lambda: keyboard.write(time), (), 0.1)
    elif config["use_mode"] == "yes_enter":
        keyboard.write(time)
Exemplo n.º 26
0
def speech_to_keyboard():

    with sr.Microphone(device_index=2) as source:

        audio = r.listen(source)

        try:
            text = r.recognize_google(audio)
            keyboard.write(text, delay=0.05)
            keyboard.press('enter')
        except:
            keyboard.write("Speech Recognition Failed", delay=0.05)
            keyboard.press('enter')
Exemplo n.º 27
0
def onPress(e):
    global s
    if len(e.name) == 1 and ('a' <= e.name <= 'z' or 'A' <= e.name <= 'Z'
                             or e.name == "'" or e.name == "#"):
        s += e.name
        s = s[-2:]
        if e.name in mapping:
            keyboard.send('backspace')
            keyboard.write(mapping[e.name])
        if s in mapping:
            for _ in range(2):
                keyboard.send('backspace')
            keyboard.write(mapping[s])
Exemplo n.º 28
0
def type(text_class, lower_delay, upper_delay):
    text = driver.find_element_by_class_name(text_class).text

    for char in text:
        # Set a random delay, the values inside randint are milliseconds
        delay = random.randint(lower_delay, upper_delay) / 1000

        # Keybr uses ␣ for spaces. So if ␣ occurs, type a space. Otherwise, write
        if char == "␣":
            sleep(delay)
            keyboard.press_and_release('space')
        else:
            keyboard.write(char, delay)
Exemplo n.º 29
0
def scan_box():
    '''
    Sends commands to the keyboard.
    '''

    countdown(3)

    counter = 0
    while counter < MAX_RECORDS:
        for word in list:
            keyboard.write(word)
            keyboard.press_and_release('return')
            counter += 1
Exemplo n.º 30
0
def down(key):
    try:
        #if not keyboard.is_pressed(key):
        if key == '?':
            keyboard.write('?', delay=0, restore_state_after=True, exact=True)
            print("write ?")
        elif key == 'asciicircum':
            keyboard.write('^', delay=0, restore_state_after=True, exact=True)
            print("^")
        else:
            keyboard.press(key)
    except:
        print("Key Invalid")
Exemplo n.º 31
0
    def update(self, observable, actions):

        (addedcards, removedcards) = actions

        for card in addedcards:
            if 'ACR122U' not in card.reader:
                print('Detected another reader added card.')
                continue
            print("+ Inserted:", toHexString(card.atr))

            if not card.atr:
                print("Did not correctly detected card insert")
                continue

            if card.atr != [0x3B, 0x81, 0x80, 0x01, 0x80, 0x80]:
                print("Accept Mifare DESFire EV1 only")
                observable.rmthread()
                continue

            connection = card.createConnection()
            connection.connect()
            card.connection = connection.component

            desfire = DESFire(PCSCDevice(connection.component))
            try:
                desfire.select_application(131201)
            except DESFireCommunicationError as err:
                print(err)
                continue
            except IndexError as err:
                print('Too Fast to remove card')
                continue

            try:
                data = desfire.read_data_file(12)
                std_id = bytes(data).decode('utf-8')[:10]
                print('DATA:', std_id)
                keyboard.write(std_id)
                keyboard.send('enter')
            except IndexError as err:
                print('Too Fast to remove card')
                continue
            except DESFireCommunicationError as err:
                print(err)
                continue

        for card in removedcards:
            if 'ACR122U' not in card.reader:
                print('Detected another reader removed card.')
                continue
            print("- Removed:", toHexString(card.atr))
Exemplo n.º 32
0
def select_acc(avatar=""):
    from lists import alist
    from lists import pas
    account = ""
    user = 0

    # for accounts in alist:
    #     if avatar in accounts[1]:
    #         # print(accounts,accounts[1].index(avatar))
    #         account = accounts[0]
    #         user = accounts[1].index(avatar)

    for accounts in alist:
        x = 0
        for acca in accounts[1]:
            if avatar in acca[0]:
                account = accounts[0]
                user = x
            x += 1
        # if avatar in accounts[1]:
        #     # print(accounts,accounts[1].index(avatar))
        #     account = accounts[0]
        #     user = accounts[1].index(avatar)

    mouse.move(2400, 800, absolute=True, duration=0)
    mouse.click(button='left')
    sleep(0.4)
    for x in range(30):
        keyboard.press_and_release('backspace')

    sleep(0.4)
    keyboard.write(account)

    sleep(0.3)
    mouse.move(2400, 840, absolute=True, duration=0)
    mouse.click(button='left')

    sleep(0.3)
    keyboard.write(pas)

    keyboard.press_and_release('enter')

    sleep(1)
    for x in range(8):
        keyboard.press_and_release('up')

    for x in range(user):
        keyboard.press_and_release('down')

    keyboard.press_and_release('enter')
    sleep(3)
Exemplo n.º 33
0
    def test_write(self):
        keyboard.write("a")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "a"), (KEY_UP, "a")])

        keyboard.write("ab")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "a"), (KEY_UP, "a"), (KEY_DOWN, "b"), (KEY_UP, "b")])

        keyboard.write("Ab")
        self.assertEqual(
            self.flush_events(),
            [(KEY_DOWN, "shift"), (KEY_DOWN, "a"), (KEY_UP, "a"), (KEY_UP, "shift"), (KEY_DOWN, "b"), (KEY_UP, "b")],
        )

        keyboard.write("\n")
        self.assertEqual(self.flush_events(), [(KEY_DOWN, "enter"), (KEY_UP, "enter")])
Exemplo n.º 34
0
 def test_write_modifiers(self):
     keyboard.write('Ab', exact=False)
     self.do([], d_shift+d_a+u_a+u_shift+d_b+u_b)
Exemplo n.º 35
0
 def test_write_multiple(self):
     last_time = time.time()
     keyboard.write('ab', delay=0.01, exact=False)
     self.do([], d_a+u_a+d_b+u_b)
     self.assertGreater(time.time() - last_time, 0.015)
Exemplo n.º 36
0
 def test_write_unicode_fallback(self):
     keyboard.write(u'áb', exact=False)
     self.do([], [KeyboardEvent(event_type=KEY_DOWN, scan_code=999, name=u'á')]+d_b+u_b)
Exemplo n.º 37
0
 def test_type_unicode(self):
     keyboard.write(u"û")
     events = self.flush_events()
     self.assertEqual(len(events), 1)
     self.assertEqual(events[0].event_type, "unicode")
     self.assertEqual(events[0].name, u"û")
Exemplo n.º 38
0
 def test_write_simple(self):
     keyboard.write('a', exact=False)
     self.do([], d_a+u_a)
Exemplo n.º 39
0
 def test_write_multiple(self):
     keyboard.write('ab', exact=False)
     self.do([], d_a+u_a+d_b+u_b)
Exemplo n.º 40
0
 def test_write_stash_restore(self):
     self.do(d_shift)
     keyboard.write('a', exact=False)
     self.do([], u_shift+d_a+u_a+d_shift)
Exemplo n.º 41
0
 def test_write_unicode_explicit(self):
     keyboard.write('ab', exact=True)
     self.do([], [KeyboardEvent(event_type=KEY_DOWN, scan_code=999, name='a'), KeyboardEvent(event_type=KEY_DOWN, scan_code=999, name='b')])