def _press(char): # Convert to pyAutoGui char if char in _ARD_TO_PYAUTOGUI_KEYS: char = _ARD_TO_PYAUTOGUI_KEYS[char] _pressed_list.append(char) pyautogui.keyDown(char) # TODO - This library does not simulate read hold down
def play(): #get sensor data s.getSensorData() #sense keypress global rc_prev rc = s.RemoteCode #remove double clicks if not (rc == rc_prev): if rc == '6C90': hmi.keyDown('up') hmi.keyUp('up') elif rc == 'CC30': hmi.keyDown('down') hmi.keyUp('down') elif rc == 'AC50': hmi.keyDown('right') hmi.keyUp('right') elif rc == '8C70': hmi.keyDown('left') hmi.keyUp('left') elif rc == '9C60': hmi.keyDown('p') hmi.keyUp('p') rc_prev = rc s.ledWrite(Red, On) wait(20) s.ledWrite(Red, Off) wait(20)
def resize(n, dir): pag.keyDown('winleft') pag.press('r') pag.keyUp('winleft') for i in range(n): pag.press(dir) pag.press('escape')
def tick(direction='right', count=0): global oldIm global newIm # no sleep but there's a long step size... is it hanging on the screenshot??? # screenGrab(count) # oldPath, newPath = None, None if count is 0: newIm = screenGrab(count) else: oldIm = newIm newIm = screenGrab(count) # shouldn't be getcwding every time # oldPath = os.getcwd() + '/caps/' + str(count - 1) + '.png' # oldPath = s # newPath = os.getcwd() + '/caps/' + str(count) + '.png' # direction = bestMove(oldPath, newPath) oldDirection = direction direction = bestMove(oldIm, newIm) if oldDirection not in ['space','sit']: pyautogui.keyUp(oldDirection) if direction not in ['space','sit']: pyautogui.keyDown(direction) # time.sleep(0.05) elif direction == "space": pyautogui.press('space') count += 1 tick(direction, count)
def do_right(area): print area if area > 33000 and pressedAtt == 0: pyautogui.keyDown("enter") pyautogui.keyUp("enter") global pressedAtt pressedAtt = 1 print "ATT" if area < 10000 and pressedDef == 0: pyautogui.keyDown("ctrlright") global pressedDef pressedDef = 1 print "DEF" else: if pressedAtt == 1 and area < 33000: global pressedAtt pressedAtt = 0 if pressedDef == 1 and area > 10000: print "DUPA" pyautogui.keyUp("ctrlright") global pressedDef pressedDef = 0
def play_music(url): webbrowser.open(url, 0, autoraise=False) time.sleep(0.1) pyautogui.keyDown("Alt") pyautogui.keyDown("Tab") pyautogui.keyUp("Alt") pyautogui.keyUp("Tab")
def close(): """ this method presses alt+f4 of the virtual key board. """ p.keyDown('alt') p.keyDown('f4') p.keyUp('f4') p.keyUp('alt')
def startup_menu(): """ this method shows the startup menu.... """ p.keyDown('alt') p.keyDown('f1') p.keyUp('f1') p.keyUp('alt')
def zoom_out(scale): pyautogui.keyDown('ctrlleft') for x in range(0,scale): print("zooming out") pyautogui.keyDown('-') pyautogui.keyUp('-') pyautogui.keyUp('ctrlleft') return True
def Tu_Dong_Go_Phim(): time.sleep(2) i = 0 while i < 10: i += 1 keyDown('enter', pause=0.25) keyUp('enter', pause=0.25) typewrite(str(i), interval=0.5)
def make(recipe): pyautogui.keyDown('down') time.sleep(2) pyautogui.keyUp('down') pyautogui.press('p') if recipe.com == 's': pyautogui.press(recipe.com) pyautogui.press('enter')
def type_this(strings): """Types the passed characters with random pauses in between strokes""" for s in strings: # delay between key presses--key UP/DOWN #autopy.key.toggle(s, True) pyautogui.keyDown(s) RandTime.randTime(0,0,0,0,0,9) pyautogui.keyUp(s)
def clicker(coordinate): # generate click event on a particular coordinate x = coordinate pyautogui.keyDown('ctrlleft') print(x) pyautogui.moveTo(x[0], x[1], duration=0.1) # This duration specifies how speed the mouse travels pyautogui.click(x[0], x[1]) pyautogui.keyUp('ctrlleft') return True
def youdao(): count = 0 time.sleep(5) while count < 90000: pag.keyDown('up') print(count) time.sleep(1) count += 1 print('done')
def cut(): """ this method presses ctrl+x of the virtual key board. """ p.keyDown('ctrl') p.keyDown('x') p.keyUp('x') p.keyUp('ctrl') notify('cut '+ clipboard.paste())
def paste(): """ this method presses ctrl+v of the virtual key board. """ p.keyDown('ctrl') p.keyDown('v') p.keyUp('v') p.keyUp('ctrl') notify('paste '+ clipboard.paste())
def copy(): """ this method presses ctrl+c of the virtual key board. """ p.keyDown('ctrl') p.keyDown('c') p.keyUp('c') p.keyUp('ctrl') notify('copy '+ clipboard.paste())
def OnKeyboardEvent(event): if chr(event.Ascii) == 'i' and event.IsAlt(): pyautogui.keyDown('alt') pyautogui.keyDown('shift') pyautogui.keyUp('shift') pyautogui.keyUp('alt') pyautogui.hotkey('ctrl', 'i') return False return True
def click_through(i): ad_spotter(i) #for i in range(0,3): # pyautogui.click() time.sleep(2) #pyautogui.click() #close_tab() pyautogui.keyDown('command') pyautogui.press('w') pyautogui.keyUp('command')
def key_down(self, key, down_tm: float): """ Custom sleep time for when a key needs to be held down for a cooking recipe :param down_tm: sleep time """ pyautogui.keyDown(key, _pause=False) time.sleep(down_tm) pyautogui.keyUp(key, _pause=False) time.sleep(self.key_press_sleep)
def keypress(cmd): FNKEY = ['ctrl', 'alt'] keys = cmd.lower().split('-') for key in keys: if key in FNKEY: pyautogui.keyDown(key) else: pyautogui.press(key) for key in keys: if key in FNKEY: pyautogui.keyUp(key)
def moveCharToTheLeftOfFM(self): CharIsLeft = False pyautogui.keyDown('left') while not CharIsLeft: im = pyautogui.screenshot(region=(0, 0, 800, 600)) left = im.getpixel((9, 138)) if 212 < left[0] and left[0] < 224: if 200 < left[1] and left[1] < 208: if 14 < left[2] and left[2] < 18: CharIsLeft = True pyautogui.keyUp('left')
def play(): pyautogui.hotkey('winleft', '9') time.sleep(0.5) pyautogui.hotkey('ctrl', 't') pyautogui.typewrite('http://www.kanyezone.com/', interval = 0.05) pyautogui.press('enter') time.sleep(4) # pyautogui.press('enter') pyautogui.keyDown('right') time.sleep(0.25) pyautogui.keyUp('right') tick()
def click(x=None, y=None, keydown=None): if x is None: pyautogui.click() return if keydown: pyautogui.keyDown(keydown) pyautogui.click(x, y) if keydown: pyautogui.keyUp(keydown)
def SendKey( self, aKey ): if self.doTimeStamp: print( "press %5s @ %15.3f" % (aKey, time.time()) ) pyautogui.keyDown(aKey) if self.doTimeStamp: print( "press %5s @ %15.3f" % (aKey, time.time()) ) time.sleep( self._pressKeySec ) if self.doTimeStamp: print( "upkey %5s @ %15.3f" % (aKey, time.time()) ) pyautogui.keyUp(aKey) if self.doTimeStamp: print( "upkey %5s @ %15.3f" % (aKey, time.time()) ) time.sleep( self._gap2KeySec )
def setkey(self, keyAct, key, debug=False): if keyAct == 11: if debug: print "\n", "set up, key: ", self.keys[key], "\n" pyautogui.keyUp(self.keys[key]) elif keyAct == 10: if debug: print "set down, key: ", self.keys[key] pyautogui.keyDown(self.keys[key]) else: if debug: print keyAct, key
def run_driver(button_bindings=ButtonBindings()): pyautogui.PAUSE = 0 # No delay when pressing/releasing keys with HESInterface() as controller: while True: action, button = controller.read_data() key = button_bindings.translate_button(button) if key: if action == 'P': # pressed pyautogui.keyDown(key) # Note: Don't worry if by holding down the button it doesn't repeat the key in a text editor. # The key is held down (try it in a game) but it isn't firing periodic keyDown()'s like keyboards do if action == 'R': # released pyautogui.keyUp(key) sleep(settings.poll_delay)
def example(): screenWidth, screenHeight = pag.size() currentMouseX, currentMouseY = pag.position() pag.moveTo(500, 550) pag.click() pag.moveRel(None, 10) # move mouse 10 pixels down pag.doubleClick() # pag.moveTo(500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad) # use tweening/easing function to move mouse over 2 seconds. pag.typewrite('Hello world!', interval=0.25) # type with quarter-second pause in between each key pag.press('esc') pag.keyDown('shift') pag.press(['left', 'left', 'left', 'left', 'left', 'left']) pag.keyUp('shift') pag.hotkey('ctrl', 'c') delta_y = 50
def type_with_keys_down(self, text, *keys): """Press keyboard keys down, then write given text, then release the keyboard keys. See valid keyboard keys in `Press Combination`. Examples: | Type with keys down | write this in caps | Key.Shift | """ valid_keys = self._validate_keys(keys) for key in valid_keys: ag.keyDown(key) ag.typewrite(text) for key in valid_keys: ag.keyUp(key)
def alt_tab(): """ this method takes the control to the previously opened window. """ if os.environ['XDG_CURRENT_DESKTOP'] == 'Unity': p.keyDown('alt') p.keyDown('\t') p.keyUp('\t') p.keyUp('alt') elif os.environ['XDG_CURRENT_DESKTOP'].lower() == 'mate': p.keyDown('alt') p.keyDown('shift') p.keyDown('\t') p.keyUp('\t') p.keyUp('shift') p.keyUp('alt')
def pressSpace(): pyautogui.keyDown('space') time.sleep(0.05) print('Jump') pyautogui.keyUp('space')
def cadastroItem(is_SINAPI, primeiraVez, codigo, descricao, unidade, precoUnitario, bdi, quantidades): time.sleep(2) pyautogui.PAUSE = time0 if primeiraVez == 1: pyautogui.keyDown('alt') pyautogui.hotkey('tab') pyautogui.keyUp('alt') #pyautogui.confirm('Prosseguir0') pyautogui.hotkey('tab') pyautogui.hotkey('enter') pyautogui.PAUSE = 2 #image = pyautogui.locateOnScreen('detect_my_job1.png') #while image != None: # print('prosseguir 1') # image = pyautogui.locateOnScreen('detect_my_job.png') time.sleep(2) #im = pyautogui.screenshot('test1-1.png', region=(660,560, 80, 40)) #im = pyautogui.screenshot('test1-1-trabalho.png', region=(670,490, 80, 30)) im = pyautogui.screenshot('test1-1-trabalho.png', region=(670, 460, 80, 30)) imgplot = plt.imshow(im) plt.show() im2 = Image.open("aguarde_trabalho.png") equalImages = equals(im, im2) print(equalImages) while equalImages == True: im = pyautogui.screenshot('test1-2-trabalho.png', region=(670, 460, 80, 30)) equalImages = equals(im, im2) print('cadastro item stop 1') #pyautogui.confirm('Prosseguir1') #pyautogui.PAUSE = time2 pyautogui.hotkey('right') pyautogui.PAUSE = 2 im = pyautogui.screenshot('test2-1-trabalho.png', region=(670, 490, 80, 30)) equalImages = equals(im, im2) while equalImages == True: im = pyautogui.screenshot('test.png', region=(670, 490, 80, 30)) equalImages = equals(im, im2) print('cadastro item stop 2') #pyautogui.confirm('Prosseguir2') pyautogui.hotkey('tab') pyautogui.PAUSE = time0 #pyautogui.hotkey('down') pyautogui.typewrite(str(n_evento), interval=0.001) if n_evento >= 10: time.sleep(3) pyautogui.typewrite(str(n_evento), interval=0.001) pyautogui.PAUSE = time1 pyautogui.hotkey('tab') pyautogui.PAUSE = 0.25 pyautogui.hotkey('tab') pyautogui.PAUSE = 2 if is_SINAPI == 1: # eh SINAPI pyautogui.hotkey('s') pyautogui.PAUSE = 1 pyautogui.hotkey('tab') pyautogui.hotkey('enter') im = pyautogui.screenshot('test2.png', region=(970, 495, 90, 25)) imgplot = plt.imshow(im) plt.show() imlupapesquisar = Image.open("lupaPesquisar.png") equalImages = equals(im, imlupapesquisar) #while equalImages == False: im = pyautogui.screenshot('test2.png', region=(970, 495, 200, 100)) # equalImages = equals(im, imlupapesquisar) # print(equalImages) #pyautogui.confirm('Prosseguir - clicou na lupa?') pyautogui.hotkey('shift', 'tab') pyautogui.hotkey('left') pyautogui.hotkey('tab') ##pyautogui.keyDown('alt') ##if primeiraVez == 1: ## pyautogui.hotkey('tab') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') #copia e cola o CODIGO ##pyautogui.hotkey('ctrl','c') #copia e cola o CODIGO ##pyautogui.hotkey('right') ##pyautogui.hotkey('right') ##pyautogui.hotkey('right') ##pyautogui.hotkey('right') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') pyautogui.PAUSE = 0.5 pyautogui.typewrite(codigo, interval=0.1) #pyautogui.hotkey('ctrl','v') pyautogui.hotkey('tab') pyautogui.hotkey('enter') pyautogui.PAUSE = 2 time.sleep(3) #pyautogui.confirm('Prosseguir - PRONTO PARA APERTAR ENTER?') pyautogui.hotkey('enter') pyautogui.hotkey('tab') pyautogui.hotkey('tab') pyautogui.hotkey('tab') pyautogui.hotkey('enter') pyautogui.PAUSE = 2 #copia e cola o CUSTO UNITÁRIO ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') time.sleep(3) #pyautogui.confirm('Prosseguir - NO EXCEL PRONTO COPIAR CUSTO?') ##pyautogui.hotkey('ctrl','c') #pyautogui.confirm('Prosseguir - COPIOU O CUSTO?') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') pyautogui.typewrite(precoUnitario, interval=0.1) ##pyautogui.hotkey('ctrl','v') if is_SINAPI == 0: #nao eh SINAPI, eh CPOS, SIURB,... pyautogui.hotkey('o') pyautogui.PAUSE = time2 pyautogui.hotkey('tab') pyautogui.PAUSE = 0.25 #copy and paste CODIGO ##pyautogui.keyDown('alt') ##if primeiraVez == 1: ## pyautogui.hotkey('tab') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') ##pyautogui.hotkey('ctrl','c') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') pyautogui.PAUSE = 0.5 #pyautogui.hotkey('tab') #pyautogui.keyDown('alt') #pyautogui.confirm('Prosseguir3 - pronto para colar o codigo') pyautogui.typewrite(codigo, interval=0.1) ##pyautogui.hotkey('ctrl','v') #fim do copia e cola pyautogui.hotkey('tab') #copy and paste #descricao #pyautogui.confirm('Prosseguir3-1 - o codigo deveria ir para o excel e copiar a descricao') pyautogui.PAUSE = 0.25 ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') #pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') ##pyautogui.hotkey('right') ##pyautogui.hotkey('ctrl','c') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') #pyautogui.hotkey('tab') #pyautogui.typewrite( descricao, interval=0.1) xerox.copy(descricao) xerox.paste() pyautogui.hotkey('ctrl', 'v') #fim do copia e cola #pyautogui.hotkey('tab') #copia e cola a UNIDADE ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') ##pyautogui.hotkey('right') ##pyautogui.hotkey('ctrl','c') #OBS: criar mecanismo para analisar termo copiado ##win32clipboard.OpenClipboard() ##unidade = win32clipboard.GetClipboardData() ##print(unidade) ##win32clipboard.CloseClipboard() #pyautogui.confirm('Prosseguir3-1-1 - copiou a unidade?') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') pyautogui.PAUSE = 2 pyautogui.hotkey('tab') pyautogui.hotkey('space') pyautogui.typewrite(unidade, interval=0.1) #pyautogui.confirm('Prosseguir3-2 - tudo certo com a unidade?') pyautogui.PAUSE = 1 #UNIDADE #pyautogui.confirm('Prosseguir3-2 COLOCAR UNIDADE') #pyautogui.typewrite(unidade, interval=0.1) pyautogui.hotkey('tab') #copy and paste #custo referencia pyautogui.PAUSE = 0.25 ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') pyautogui.PAUSE = 0.25 #pyautogui.hotkey('right') ##pyautogui.hotkey('right') ##pyautogui.hotkey('right') ##pyautogui.hotkey('ctrl','c') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') pyautogui.PAUSE = time1 #pyautogui.hotkey('tab') pyautogui.typewrite(precoUnitario, interval=0.1) ##pyautogui.hotkey('ctrl','v') #fim do copia e cola pyautogui.hotkey('tab') #custo unitario ##pyautogui.hotkey('ctrl','v') pyautogui.typewrite(precoUnitario, interval=0.1) #COMUM PARA TANTO SINAPI COMO PARA AS OUTRAS TABELAS pyautogui.PAUSE = 1 pyautogui.hotkey('tab') #pyperclip.copy(bdi) #pyperclip.paste() xerox.copy(bdi) pyautogui.hotkey('ctrl', 'v') #pyautogui.typewrite( bdi, interval=1) pyautogui.PAUSE = 0.25 #com eventos pyautogui.hotkey('tab') #pyautogui.hotkey('down') pyautogui.typewrite(str(n_evento), interval=0.1) #fim com eventos #copy and paste #quantidade (COM EVENTOS) pyautogui.PAUSE = 0.25 pyautogui.hotkey('tab') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') pyautogui.PAUSE = 0.25 #pyautogui.hotkey('left') antes pegava da propria PO ##pyautogui.hotkey('ctrl','pagedown') #muda para a aba CALCULO ##pyautogui.hotkey('ctrl','c') pyautogui.PAUSE = 1 for x in range(1, n_frentes + 1): #pyautogui.typewrite(quantidades[x-1], interval=0.1) time.sleep(2) xerox.copy(quantidades[x - 1]) pyautogui.hotkey('ctrl', 'v') pyautogui.hotkey('tab') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') #muda para o excel ##if x != n_frentes+1: ## pyautogui.hotkey('right') ## pyautogui.hotkey('ctrl','c') ## print(x) #if x == (n_frentes): print('aqui') ##pyautogui.hotkey('down') ##for y in range (1, n_frentes+1): #deixa o cursor na primeira frente do proximo item ## pyautogui.hotkey('left') ##pyautogui.hotkey('ctrl', 'pageup') #volta para a aba PO ##pyautogui.hotkey('down') ##pyautogui.hotkey('left') ##pyautogui.hotkey('left') ##pyautogui.hotkey('left') ##pyautogui.hotkey('left') #deixa o cursor no codigo do proximo item na PO ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') #muda para o siconv pyautogui.hotkey('tab') pyautogui.hotkey('tab') pyautogui.hotkey('enter') #aperta salvar no siconv im = pyautogui.screenshot('test1-1-trabalho.png', region=(670, 490, 80, 30)) imgplot = plt.imshow(im) plt.show() im2 = Image.open("aguarde_trabalho.png") equalImages = equals(im, im2) print(equalImages) while equalImages == True: im = pyautogui.screenshot('test1-2-trabalho.png', region=(670, 490, 80, 30)) equalImages = equals(im, im2) print('cadastro item stop 1')
def keyboard_key_down(key, interval: float = 0.2) -> None: pyautogui.keyDown(key, interval=interval)
def ComandoTeclas(Teclas): for tecla in Teclas: pyautogui.keyDown(tecla) for tecla in reversed(Teclas): pyautogui.keyUp(tecla)
x2 = 450 y2 = 120 im = pyautogui.screenshot(region=(x1, y1, x2, y2)) print(im.getpixel((0, 0))) while True: im = pyautogui.screenshot(region=(x1, y1, x2, y2)) for i in range(x1, x1 + x2): x3 = i - x1 y3 = clamp((y1+y1+y2)/2, 0, y2 - 1) #print() #print("se scaneaza ", (x3, y3), ", culoarea = ", im.getpixel((x3, y3))) #print(im.getpixel((x3, y3)) == (66,245,0)) if pyautogui.pixelMatchesColor(1105, 155, (190,80,154), tolerance=50): print("stanga") pyautogui.keyDown('left') pyautogui.keyUp('left') #time.sleep(0.09) elif pyautogui.pixelMatchesColor(1263, 151, (2,255,250), tolerance=50): print("jos") pyautogui.keyDown('down') pyautogui.keyUp('down') #time.sleep(0.09) elif pyautogui.pixelMatchesColor(1425, 140, (18,251,10), tolerance=50): print("sus") pyautogui.keyDown('up') pyautogui.keyUp('up') #time.sleep(0.09)
def press(): if pyautogui.pixel(340, 880)[0] == 252: pyautogui.keyDown('d') if pyautogui.pixel(340, 916)[0] == 0: time.sleep(np.random.uniform(0.5, 0.7)) pyautogui.keyUp('d')
import pyautogui while True: pyautogui.keyDown('space')
import pyautogui, time pyautogui.typewrite(["win"]) #time.sleep(0.25) pyautogui.typewrite("thispc") time.sleep(0.25) pyautogui.typewrite(["enter"]) time.sleep(0.25) pyautogui.typewrite("dvd") #time.sleep(0.25) pyautogui.typewrite(["enter"]) time.sleep(1) pyautogui.typewrite(["enter"]) pyautogui.keyDown("alt") pyautogui.press(["f4"]) pyautogui.keyUp("alt")
def minimize(): pyautogui.keyDown('win') keyboard.press(Key.down) pyautogui.keyUp('win')
text = colored('iostream headerfile is missing...', 'green') print(err + text) # x-axis -- COMMON Y = 525 # -- x DIFF = 198 (-1085 to -292) #251 , 335, 417, 506, 586, 673 def menudrive(): global k #print(pyautogui.position()) for i in range(251, 678, 85): for j in range(-1085, -292, 198): k = k + 1 if k <= 100: pyautogui.click(j, i) time.sleep(3) SelectCode() time.sleep(1) pyautogui.click(-623, 64) k = 0 for menu in range(4): time.sleep(0.5) menudrive() #pyautogui.click(-1262, 307) pyautogui.keyDown('pagedown') #print(pyautogui.position()) #SelectCode()
final = [] flag = 0 while 1: for counter in range(0, 16): flag = 0 for i in range(0, 256): decrypted_password = '' if counter != 0: decrypted_password = final[counter - 1] decrypted_password += outtab[i / 16] + outtab[i % 16] pyautogui.click(1187, 691) pyperclip.copy(decrypted_password) pyautogui.keyDown('ctrl') pyautogui.keyDown('v') pyautogui.keyUp('v') pyautogui.keyUp('ctrl') pyautogui.press('enter') time.sleep(0.01) pyautogui.click(442, 687) pyautogui.click(442, 687) pyautogui.click(442, 687) pyautogui.keyDown('ctrl') pyautogui.keyDown('c') pyautogui.keyUp('c') pyautogui.keyUp('ctrl') text = pyperclip.paste() f2.write(decrypted_password + ":" + text + "\n\n")
import serial # add Serial library for serial communication import pyautogui # add pyautogui library for programmatically controlling the mouse and keyboard. Arduino_Serial = serial.Serial('com3',9600) # Initialize serial and Create Serial port object called Arduino_Serial while 1: incoming_data = str (Arduino_Serial.readline()) # read the serial data and print it as line print (incoming_data) # print the incoming Serial data if 'next' in incoming_data: # if incoming data is 'next' pyautogui.hotkey('ctrl', 'pgdn') # perform "ctrl+pgdn" operation which moves to the next tab if 'previous' in incoming_data: # if incoming data is 'previous' pyautogui.hotkey('ctrl', 'pgup') # perform "ctrl+pgup" operation which moves to the previous tab if 'down' in incoming_data: # if incoming data is 'down' #pyautogui.press('down') # performs "down arrow" operation which scrolls down the page pyautogui.scroll(-100) if 'up' in incoming_data: # if incoming data is 'up' #pyautogui.press('up') # performs "up arrow" operation which scrolls up the page pyautogui.scroll(100) if 'change' in incoming_data: # if incoming data is 'change' pyautogui.keyDown('alt') # performs "alt+tab" operation which switches the tab pyautogui.press('tab') pyautogui.keyUp('alt') incoming_data = ""; # clears the data
def pressSpace(): pyautogui.keyDown('space') time.sleep(0.23) pyautogui.keyUp('space')
import pyautogui, time time.sleep(4) m = open("Shrek.txt","r") pyautogui.keyDown('alt') pyautogui.press(['tab']) pyautogui.keyUp('alt') for each_line in m: pyautogui.typewrite(each_line) pyautogui.press('enter') #for i in range(100): #pyautogui.write('Eu sou o mario\nA princesa esta em outro castelo\nIts me Mario ') #pyautogui.press('enter') # pyautogui.press(['left','right'])
def forward_move(step): pyautogui.keyDown(direct_dict[step % 4]) time.sleep(step) pyautogui.keyUp(direct_dict[step % 4])
def maximize(): pyautogui.keyDown('win') keyboard.press(Key.up) pyautogui.keyUp('win')
def keyboard(): # ================== setup myo-python (do not change) ===================== myo.init(sdk_path="../../myo_sdk") # Compile Python binding to Myo's API hub = myo.Hub() # Create a Python instance of MYO API if not ConnectionChecker().ok: # Check connection before starting acquisition: quit() # ========================================================================= # Parce command line inputs, if any input_file = "../classification/models/trained_model.pkl" if len(sys.argv) > 1: input_file = sys.argv[1] # Load pickled feature extractor and classification model with open(input_file, "rb") as file: model = pickle.load(file) # Extract variables from pickled object mdl = model["mdl"] feature_extractor = model["feature_extractor"] gestures = model["gestures"] # Set up the buffer that will always contain the most up-to-date readings from the MYO emg_buffer = Buffer(feature_extractor.winlen) # Set up inference with hub.run_in_background(emg_buffer.on_event): print("You may start performing gestures. Press ctrl-c to stop.") while hub.running: time.sleep(0.050) # Skip the rest until enough data for feature extraction is acquired if len(emg_buffer.emg_data_queue) < feature_extractor.winlen: continue # Get latest emg data emg = emg_buffer.get_emg_data() # Convert to a numpy matrix (an Nx8 matrix, each channel is a column): emg = np.array([x[1] for x in emg]) # Extract features from the emg signal: feature_vector = feature_extractor.extract_feature_vector(emg) # Use classification model to recognise the gesture: inference = mdl.predict(feature_vector) # Implement majority voting here, if needed: # ... # Output inference: print("\rRecognized gesture: ", gestures[inference[0]], end="") gesture = gestures[inference[0]] if gesture == 'rest': continue #pyautogui.press('w') elif gesture == 'radial': pyautogui.keyDown('a') elif gesture == 'ulnar': pyautogui.keyDown('d') elif gesture == 'flextion': pyautogui.keyDown('w') elif gesture == 'extension': pyautogui.keyDown('s') elif gesture == 'fist': pyautogui.keyDown('space')
def pressSapce(): pyautogui.keyDown('space') #time.sleep(0.005) print("Jump") pyautogui.keyUp('space')
pyautogui.doubleClick(1546, 36) pyautogui.PAUSE = 1 pyautogui.click(975, 470) pyautogui.pause = 1 #TODO : 로그인하기 pyautogui.click(1230, 710) pyperclip.copy('admin') pyautogui.hotkey('ctrl', 'v') pyautogui.typewrite('\n') pyautogui.typewrite('1230') pyautogui.typewrite('\n') pyautogui.click(655, 367) time.sleep(1) pyautogui.hotkey('alt', 'space', 'x') pyautogui.keyDown('altleft') pyautogui.keyUp('altleft') pyautogui.press('right') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('enter') #TODO : 개인별검진현황 일자 조회 pyautogui.click(101, 83) pyautogui.click(668, 84) pyautogui.press('1') pyautogui.press('0') pyautogui.click(693, 84) pyautogui.press('0') pyautogui.press('4')
return frame, smile_status def press_space(): pyautogui.keyUp('down') # releasing the Down Key pyautogui.keyDown('space') # pressing Space to overcome Bush time.sleep(0.05) # so that Space Key will be recognized easily print("jump") # printing the "Jump" statement on the time.sleep(0.10) # terminal to see the current output pyautogui.keyUp('space') # releasing the Space Key pyautogui.keyDown( 'down') # again pressing the Down Key to keep my Bot always down pyautogui.keyDown('down') #keeps the 'down' button pressed by default cap = cv2.VideoCapture(0) while True: _, frame = cap.read() # Captures cap frame by frame gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # To capture image in monochrome canvas, smileStatus = detect(gray, frame) # calls the detect() function if smileStatus: press_space() # Displays the result on camera feed cv2.imshow('Video', canvas)
def callOutlook(self): global count global f1 global f2 pyautogui.click(1280, 1200) pyautogui.keyDown('win') time.sleep(1) pyautogui.keyUp('win') pyautogui.typewrite('Outlook') time.sleep(1) pyautogui.press('enter') #pyautogui.click(142,504) time.sleep(4) window = win32gui.GetForegroundWindow() win32gui.ShowWindow(window, win32con.SW_MAXIMIZE) pyautogui.click(67, 100) time.sleep(0.5) pyautogui.click(82, 181) time.sleep(0.5) window = win32gui.GetForegroundWindow() win32gui.ShowWindow(window, win32con.SW_MAXIMIZE) y = name1.strip().split(",") pyautogui.click(375, 207) for a in y: pyautogui.typewrite(a) pyautogui.keyDown('ctrl') pyautogui.keyDown('k') pyautogui.keyUp('ctrl') pyautogui.keyUp('k') pyautogui.click(392, 238) time.sleep(1) pyautogui.typewrite(sub) pyautogui.click(236, 292) for j in range(15): pyautogui.keyDown('backspace') pyautogui.keyUp('backspace') pyautogui.typewrite(date) time.sleep(1) #floor decision f1 = floor_[0] f2 = int(floor_[1]) #new changes pyautogui.click(1155, 395) pyautogui.click(1254, 455) pyautogui.click(1254, 455) pyautogui.click(1254, 455) pyautogui.click(1254, 455) pyautogui.click(1254, 455) pyautogui.click(1254, 455) pyautogui.click(1254, 455) pyautogui.click(1188, 414) if tower_ == "T2": pyautogui.keyDown('down') pyautogui.keyUp('down') if f1 == 'C': pyautogui.keyDown('down') pyautogui.keyUp('down') if f1 == 'N': pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') if f1 == 'S': pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') if tower_ == "T6": pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') if tower_ == "T7": pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') pyautogui.keyDown('down') pyautogui.keyUp('down') time.sleep(3) pyautogui.click(1163, 635) pyautogui.click(1163, 635) time.sleep(1) pyautogui.click(1254, 617) pyautogui.click(1254, 617) pyautogui.click(1254, 617) pyautogui.click(1254, 617) pyautogui.click(1254, 617) pyautogui.click(1254, 617) pyautogui.click(1254, 617) time.sleep(3) if stime == "08:30 AM": count = 1 if stime == "09:00 AM": count = 2 if stime == "09:30 AM": count = 3 if stime == "10:00 AM": count = 4 if stime == "10:30 AM": count = 5 if stime == "11:00 AM": count = 6 if stime == "11:30 AM": count = 7 if stime == "12:00 PM": count = 8 if stime == "12:30 PM": count = 9 if stime == "01:00 PM": count = 10 if stime == "01:30 PM": count = 11 if stime == "02:00 PM": count = 12 if stime == "02:30 PM": count = 13 if stime == "03:00 PM": count = 14 if stime == "03:30 PM": count = 15 if stime == "04:00 PM": count = 16 if stime == "04:30 PM": count = 17 print count for x in range(count): pyautogui.keyDown('down') pyautogui.keyUp('down') time.sleep(5) pyautogui.click(398, 309) for j in range(15): pyautogui.keyDown('backspace') pyautogui.keyUp('backspace') pyautogui.typewrite(etime) pyautogui.click(1152, 454) time.sleep(2) pyautogui.click(1280, 1200) tkMessageBox.showinfo("Window", "Click on 'Send' to arrange a meeting") time.sleep(1)
def controller(): global MYMSG while True: if MYMSG.strip().lower() == "up": pyautogui.keyDown("up") MYMSG = "" pyautogui.keyUp("up") elif MYMSG.strip().lower() == "down": pyautogui.keyDown("down") MYMSG = "" pyautogui.keyUp("down") elif MYMSG.strip().lower() == "left": pyautogui.keyDown("left") MYMSG = "" pyautogui.keyUp("left") elif MYMSG.strip().lower() == "right": pyautogui.keyDown("right") MYMSG = "" pyautogui.keyUp("right") elif MYMSG.strip().lower() == "a": pyautogui.keyDown("up") MYMSG = "" pyautogui.keyUp("up") elif MYMSG.strip().lower() == "b": pyautogui.keyDown("up") MYMSG = "" pyautogui.keyUp("up") elif MYMSG.strip().lower() == "start": pyautogui.keyDown("up") MYMSG = "" pyautogui.keyUp("up") elif MYMSG.strip().lower() == "select" or MYMSG.strip().lower == "sel": pyautogui.keyDown("up") MYMSG = "" pyautogui.keyUp("up") elif MYMSG.strip().lower() == "l": pyautogui.keyDown("up") MYMSG = "" pyautogui.keyUp("up") elif MYMSG.strip().lower() == "r": pyautogui.keyDown("r") MYMSG = "" pyautogui.keyUp("r") else: pass
def paste(): pyautogui.keyDown('ctrl') pyautogui.press('v') pyautogui.keyUp('ctrl')
def click_key(key, delay=.1): auto.keyDown(key) time.sleep(delay) auto.keyUp(key)
def goTo(): while True: date = datetime.datetime.now().strftime("%d") if date == '1': py.moveTo(682, 175) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '2': py.moveTo(682, 198) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '3': py.moveTo(682, 219) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '4': py.moveTo(682, 244) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '5': py.moveTo(682, 265) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '6': py.moveTo(682, 286) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '7': py.moveTo(682, 308) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '8': py.moveTo(682, 330) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '9': py.moveTo(682, 352) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '10': py.moveTo(682, 373) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '11': py.moveTo(682, 396) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '12': py.moveTo(682, 417) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '13': py.moveTo(682, 441) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '14': py.moveTo(682, 463) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '15': py.moveTo(682, 484) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '16': py.moveTo(682, 506) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '17': py.moveTo(682, 527) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '18': py.moveTo(682, 551) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '19': py.moveTo(682, 572) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '20': py.moveTo(682, 594) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '21': py.moveTo(682, 616) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '22': py.moveTo(682, 637) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '23': py.moveTo(682, 659) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '24': py.moveTo(682, 682) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '25': py.moveTo(682, 705) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '26': py.moveTo(682, 726) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '27': py.moveTo(682, 749) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '28': py.moveTo(682, 771) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '29': py.moveTo(682, 790) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '30': py.moveTo(682, 812) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break if date == '31': py.moveTo(682, 834) py.click(button='left', clicks=3) time.sleep(0.5) py.keyDown('Ctrl') py.keyDown('c') py.keyUp('Ctrl') py.keyUp('c') os.system('Main.py') break
x, y, w, h = cv2.boundingRect(c) if x > 150 and is_once == True: dist = x is_once = False if x == 0 and is_once == False: is_once = True # cv2.rectangle(image, (x, y), (x+w, y+h), (0, 0, 255), 2) front_cx, front_cy = x, y + (h // 2) xdist_to_lookup = front_cx - LOOKUP_POINT[1] ydist_to_lookup = LOOKUP_POINT[0] - front_cy if xdist_to_lookup <= X_LIMIT and ydist_to_lookup < 10: pg.press("up") elif xdist_to_lookup <= X_LIMIT and ydist_to_lookup > 10 and ydist_to_lookup < 18: pg.keyDown("down") time.sleep(delay) pg.keyUp("down") else: pass # cv2.imshow("screen", image) if cv2.waitKey(1) & 0xFF == ord('q'): break
def cadastroMacroItem(primeiraVez, descricaoMacro): time.sleep(2) pyautogui.PAUSE = 1 if primeiraVez == 1: pyautogui.keyDown('alt') pyautogui.hotkey('tab') pyautogui.keyUp('alt') pyautogui.hotkey('tab') pyautogui.hotkey('enter') time.sleep(2) im = pyautogui.screenshot('test1-1-trabalho.png', region=(670, 490, 80, 30)) imgplot = plt.imshow(im) plt.show() im2 = Image.open("aguarde_trabalho.png") equalImages = equals(im, im2) print(equalImages) while equalImages == True: im = pyautogui.screenshot('test1-2-trabalho.png', region=(670, 490, 80, 30)) equalImages = equals(im, im2) print('cadastro item stop 1') #pyautogui.confirm('Prosseguir1') time.sleep(2) pyautogui.hotkey('space') #seleciona macroservico pyautogui.hotkey('tab') pyautogui.hotkey('tab') ##pyautogui.keyDown('alt') #muda para o excel para copiar #e colar nome do macroservico ##pyautogui.hotkey('tab') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') ##pyautogui.hotkey('right') ##pyautogui.hotkey('ctrl', 'c') ##pyautogui.hotkey('down') ##pyautogui.hotkey('left') ##pyautogui.hotkey('ctrl', 'pagedown') ##pyautogui.hotkey('down') ##pyautogui.hotkey('ctrl', 'pageup') ##pyautogui.keyDown('alt') ##pyautogui.hotkey('tab') ##pyautogui.keyUp('alt') ##pyautogui.hotkey('ctrl', 'v') ####### ##pyautogui.typewrite(descricaoMacro, interval=0.1) xerox.copy(descricaoMacro) xerox.paste() pyautogui.hotkey('ctrl', 'v') pyautogui.hotkey('tab') pyautogui.hotkey('tab') pyautogui.hotkey('enter') im = pyautogui.screenshot('test1-1-trabalho.png', region=(670, 490, 80, 30)) imgplot = plt.imshow(im) plt.show() im2 = Image.open("aguarde_trabalho.png") equalImages = equals(im, im2) print(equalImages) while equalImages == True: im = pyautogui.screenshot('test1-2-trabalho.png', region=(670, 490, 80, 30)) equalImages = equals(im, im2) print('cadastro macroitem stop 1')
def url2mff2datei(url, ausgabe): ### MODUL ### import shutil ### KONSTANT ### datei = re.sub('.+/', '', url) datei = NLPFAD + datei teil = datei + '.part' if '/' in ausgabe: ausgabe2 = ausgabe else: ausgabe2 = NLPFAD + ausgabe # print( datei ) #d # print( ausgabe2 ) #d if os.path.exists(ausgabe2): x = 'Passiert %s...' % ausgabe print(x) return True if os.path.exists(datei): shutil.move(datei, ausgabe2) x = 'Bewegt %s...' % ausgabe print(x) return True # x = 'Nehmen %s...' % ausgabe wb.open(url) # wb.open_new_tab(url) # xu.sleep(2) # pgui.click(x=1000, y=500) # pgui.keyDown('ctrl') # pgui.press('w') # pgui.keyUp('ctrl') # key = 0 i = 0 kein = 0 for zt in range(30): i += 1 if os.path.exists(teil): if not key == 1: print("\nSLEEP / Teil Existert : ", end='') print('%d, ' % i, end='') key = 1 xu.sleep(1) continue # try: os.path.getsize(datei) except FileNotFoundError: kein += 1 if kein == 5: print("\n- PASS / %s : " % datei, end='') break xu.sleep(1) # if os.path.getsize(datei) == 0: if not key == 2: print("\nSLEEP 2 / Get Size : ", end='') print('%d, ' % i, end='') xu.sleep(1) else: break # if os.path.getsize(datei) == 0: os.remove(datei) return False ### AUSGABE ### xu.sleep(2) xu.click(797, 16) pgui.keyDown('ctrl') pgui.press('w') pgui.keyUp('ctrl') # # print( datei ) #d # print( ausgabe ) #d shutil.move(datei, ausgabe2) return True
def hit(key): pyautogui.keyDown(key)
def reload(): pyautogui.keyDown('command') pyautogui.press('r') pyautogui.keyUp('command')