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")])
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")
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))
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))
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()
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)
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')
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)
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)
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'])
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)
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)
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"
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)
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)
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)
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
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---------------------")
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
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")
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
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)
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')
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])
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)
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
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")
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))
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)
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")])
def test_write_modifiers(self): keyboard.write('Ab', exact=False) self.do([], d_shift+d_a+u_a+u_shift+d_b+u_b)
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)
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)
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"û")
def test_write_simple(self): keyboard.write('a', exact=False) self.do([], d_a+u_a)
def test_write_multiple(self): keyboard.write('ab', exact=False) self.do([], d_a+u_a+d_b+u_b)
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)
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')])