print('-----------------------------------') print('What operation?') print() print('1.What is the Time?') print('2.Play Songs on Youtube') print('3.Maximize the current window') print('4.Minimize the current window') print('5.Search dogs on Google') print('-----------------------------------') print() time.sleep(2) with mic1 as source_again: audio1 = r.listen(source_again) command = r1.recognize_google(audio1) if command == 'maximize the window': pyautogui.getActiveWindow().maximize() elif command == 'minimise the window': pyautogui.getActiveWindow().minimize() elif command == 'play songs on YouTube': url = 'https://www.youtube.com/results?search_query=play+songs' wb.get().open_new(url) time.sleep(1) pyautogui.click(220, 220) break elif command == 'search dogs on Google': command = command.split(' ') query = command[1] url = f'https: //{query}' wb.get().open_new(url) elif command == 'Open File explorer':
import openpyxl from time import sleep import os try: os.remove('challenge.xlsx') except: pass r.init() r.url('http://rpachallenge.com/') sleep(10) r.download('http://rpachallenge.com/assets/downloadFiles/challenge.xlsx', 'challenge.xlsx') window = p.getActiveWindow() window.maximize() sleep(4) df = pd.read_excel('challenge.xlsx', sheet_name='Sheet1') datas = pd.DataFrame(df, columns=[ "First Name", "Last Name ", "Company", "Name", "Role in Company", "Address Email" "Phone Number" ]) r.click('/html/body/app-root/div[2]/app-rpa1/div/div[1]/div[6]/button') for collumn in df.itertuples(): print(collumn) r.type('//*[@ng-reflect-name="labelFirstName"]', str(collumn[1]))
def is_ark_active(): """ :return: bool - True if ark is the active window """ return pyautogui.getActiveWindow().title == "Ark: Survival Evolved"
links.append(elem.get_attribute('href')) for link in links: match = regex.search(str(link)) if match != None: index = links.index(link) logging.info("Match found.") logging.info(f"Link: {linkElems[index].get_attribute('href')}") # Click on link for that lesson in English linkElem = linkElems[index] logging.info(f"Entering page for lesson {lessonNum}...") linkElem.click() # Get top left corner coordinate window = pyautogui.getActiveWindow() topLeftCoord = window.topleft addressBarCoord = (topLeftCoord[0] + 620, topLeftCoord[1] + 60) # Click on address bar pyautogui.click(addressBarCoord) # Select address and copy to clipboard pyautogui.hotkey('ctrl', 'a') pyautogui.hotkey('ctrl', 'c') # Open Chrome browser mainURL = ('https://www.howtostudykorean.com/') webbrowser.open(mainURL) # Wait for browser to load
def __init__(self): """ # remember past_only arg from self.get_atual_competencia """ import pandas as pd from default.webdriver_utilities.pre_drivers import pgdas_driver # O vencimento DAS(seja pra qual for a compt) está certo, haja vista que se trata do mes atual sh_names = possible self.compt_used = super().get_compt_only() # datageral = self.first_and_last_day_compt(self.compt_used, '/') excel_file_name = super().excel_file_path() # ############################### #self.abre_programa('G5') # ############################### for sh_name in sh_names: # agora eu posso fazer downloalds sem me preocupar tendo a variável path mshExcelFile = pd.ExcelFile(excel_file_name) msh = mshExcelFile.parse(sheet_name=str(sh_name)) col_str_dic = {column: str for column in list(msh)} msh = mshExcelFile.parse(sheet_name=str(sh_name), dtype=col_str_dic) READ = self.le_excel_each_one(msh) self.after_READ = self.readnew_lista(READ, False) after_READ = self.after_READ for i, CNPJ in enumerate(after_READ['CNPJ']): # ####################### A INTELIGENCIA EXCEL ESTÁ SEM OS SEM MOVIMENTOS NO MOMENTO CLIENTE = after_READ['Razão Social'][i] JA_DECLARED = after_READ['Declarado'][i].upper().strip() CodSim = after_READ['Código Simples'][i] CPF = after_READ['CPF'][i] cont_ret_n_ret = i if CLIENTE == '': break if sh_name == 'G5_ICMS' and sh_name in possible: pass elif sh_name == 'G5_ISS' and sh_name in possible: self.client_path = self.files_pathit(CLIENTE) meus_3_valores_atuais = tres_valores_faturados( self.client_path) # Se tem 3valores[excel], tem XML. Se não tem, não tem # (pois o xml e excel vem do ginfess_download).... registronta = self.registronta(CLIENTE, self.compt_used) input(registronta) print(CLIENTE) if meus_3_valores_atuais and registronta: all_xls_inside = self.files_get_anexos_v3( CLIENTE, file_type='xlsx', compt=self.compt_used) relacao_notas = all_xls_inside[0] if len( all_xls_inside) == 1 else IndexError() self.activating_client(self.formatar_cnpj(CNPJ)) # Agora vai ser por cnpj... self.start_walk_menu() # access ISS lançamento pygui.hotkey('right', 'down', 'enter', 'up', 'up', 'enter', interval=.1) sleep(3.5) foritab(2, 'down') # busca XML pygui.write(self.get_xml(CLIENTE)) """IMPORTA ITENS OU NÃO""" if 'LUCRO PRESUMIDO' in CLIENTE: # aqui mais pra frente irei validar melhor SE IMPORTA ITEMS OU NÃO w = pygui.getActiveWindow() pygui.click(w.center) pygui.move(-210, 80) # Importar itens window 1 pygui.click() foritab(2, 'tab') pygui.hotkey('enter') # window 2, mt legal sleep(2) w2 = pygui.getActiveWindow() pygui.click(w2.center, clicks=0) pygui.move(65, -160) # Copiar configuração da nota...? pygui.click() pygui.hotkey('tab', 'enter') sleep(1) pygui.write('1') pygui.hotkey('enter') foritab(15, 'tab') print('Sleeping 2.5 pra enter, enter') sleep(2.5) foritab(2, 'enter', interval=1) sleep(1) pygui.hotkey('alt', 'f4') nfcanceladas = NfCanceled(relacao_notas) print('SLEEPING PARA IMPORTAR') self.importa_nfs() try: qtd_els = nfcanceladas.conta_qtd_nfs() sleep(qtd_els) except TypeError: sleep(5.5) pygui.hotkey('enter') # vai sleepar dependendo da quantidade de notas, programar ainda isso # #### recente sleep(1) pygui.keyDown('shift') foritab(2, 'tab') pygui.keyUp('shift') pygui.hotkey('enter') sleep(2) ##### """ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LE_NF_CANCELADAS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""" self.start_walk_menu() print('right down enter enter') pygui.hotkey('right', 'down', 'enter', 'enter', interval=.5) sleep(2) print('NF canceled') nfcanceladas.action() # Cancela # p.hotkey('alt', 'tab') print('NF canceled FORA') sleep(1) # generate PDF relat. Prestados 51 self.start_walk_menu() foritab(3, 'right') foritab(6, 'down') foritab(5, 'enter', interval=.25) # generate pdf sleep(7.5) # self.most_recent_file() print( 'estou contando com o Adobe, pois o PDF do G5 é aberto nele...' ) all_keys('ctrl', 'shift', 's') sleep(6) all_keys('enter') sleep(1) all_keys('ctrl', 'x') [(pygui.hotkey('alt', 'f4'), sleep(1)) for i in range(2)] path_file_temp_file = f"C:\\tmp\\{paste()}" sleep(2) filenewname = f'{self.client_path}\\Registro_ISS-{CNPJ}.pdf' while True: try: self.move_file(path_file_temp_file, filenewname) print('finally') break except PermissionError: sleep(5) break """save in adobe"""
import rpa as r import pyautogui as ui r.init() r.url('http://www.google.com') r.url() janela = ui.getActiveWindow() janela.maximize() r.wait(2.0) r.type('/html/body/div[1]/div[3]/form/div[2]/div[1]/div[1]/div/div[2]/input', 'RPA[enter]') r.wait(0.5) r.snap('page', 'rpa_page.png') r.wait(2.0) r.close()
#! python3 # Mouse_mover.py - Moves the mouse, so Gunhilde doesn't fall asleep. import pyautogui from time import sleep pyautogui.FAILSAFE = False while True: sleep(1) screen = pyautogui.getActiveWindow() active_screen_name = str(screen).split(',')[4] sleep(1800) screen = pyautogui.getActiveWindow() active_screen = str(screen).split(',')[4] if active_screen == active_screen_name: sleep(1800)
import rpa as r import pyautogui as p r.init() r.url('http://www.google.com') janela = p.getActiveWindow() janela.maximize() r.wait(2.0) r.type('//*[@id="tsf"]/div[2]/div[1]/div[1]/div/div[2]/input', 'RPA[enter]') r.wait(2.0) r.snap('page', 'rpa_page.png') r.wait(2.0) r.close()
import pyautogui as ui import rpa as r import pandas as pd import os r.init() ui.sleep(2) r.url('https://rpachallengeocr.azurewebsites.net/') ui.sleep(3) window = ui.getActiveWindow() window.maximize() countPage = 1 dados = pd.DataFrame() while countPage <= 3: # selecionando a tabela r.table('//*[@id="tableSandbox"]', 'temp.csv') dados = dados.append(pd.read_csv('temp.csv')) # clicando no next para mostrar a proxima pagina r.click('//*[@id="tableSandbox_next"]') countPage += 1 r.close() os.remove('temp.csv') print(dados) dados.to_csv(r'webtable.csv', mode='a', index=None, header=True)
while attempts > 0: pyautogui.write(names + '\n', 0.2) pyautogui.sleep(2) if pyautogui.locateOnScreen(messageImg) is None: pyautogui.click() continue break pyautogui.write(notification + '\n', 0.2) pyautogui.screenshot().save('group' + str(i) + '.png') i += 1 pyautogui.click() # Opens to site via chrome or select window with Google Hangouts open # Can be removed if don't want to open with google chrome if (pyautogui.getWindowsWithTitle('Google Chrome')) == []: threadObj = threading.Thread(target=sendingMessages, args=(people, messages)) threadObj.start() webbrowser.get(browserPath).open('https://hangouts.google.com/') else: # Select and maximize browser window print('Select window running Google Hangouts') pyautogui.sleep(5) browser = pyautogui.getActiveWindow() sendingMessages(people, messages) #browser.maximize() print('Notifications sent')
import pyautogui #### Interagindo com notepad pyautogui.hotkey('win', 'r') pyautogui.sleep(1) pyautogui.typewrite('notepad') pyautogui.sleep(2) pyautogui.press('enter') pyautogui.sleep(2) pyautogui.typewrite('Seja bem vindo ao WorkShop da FNC!') pyautogui.sleep(2) janela = pyautogui.getActiveWindow() janela.close() pyautogui.press('right') pyautogui.sleep(2) pyautogui.press('enter')
import time, pyautogui as pg from tkinter import * from PIL import ImageTk, Image fw = pg.getActiveWindow() # object for accessing active windows """------------------------------------THIS IS THE MODULE FOR PLANE AND WING DESIGN----------------------------------""" """---------------------------------------------------GUI-----------------------------------------------------------""" arr_gui = [] def save_info(): arr_gui.append(firstentry.get()) arr_gui.append(secondentry.get()) arr_gui.append(thirdentry.get()) arr_gui.append(fourthentry.get()) arr_gui.append(fifthentry.get()) arr_gui.append(sixthentry.get()) arr_gui.append(seventhentry.get()) arr_gui.append(eighthentry.get()) arr_gui.append(ninthentry.get()) arr_gui.append(tenthentry.get()) arr_gui.append(eleventhentry.get()) arr_gui.append(twelvethentry.get()) arr_gui.append(thirteenthentry.get()) arr_gui.append(fourteenthentry.get()) arr_gui.append(fifteenthentry.get()) arr_gui.append(sixteenthentry.get()) arr_gui.append(seventeenthentry.get()) arr_gui.append(eighteenthentry.get())
def importa_nfs(self): sleep(2.5) w3 = pygui.getActiveWindow() pygui.click(w3.center, clicks=0) pygui.move(0, 150) pygui.click()
time.sleep(0.5)# per te qene me konsistent pyautogui.doubleClick() image = r'C:\Users\admin.erinm\Desktop\DPMIMage\content.PNG' error_message = "Programi eshte duke kerkuar content te " + imglist[i] content_location = image_recognition(image, error_message, 0.9) # pjesa poshte nuk do ekzekutohet 1 here if i == 4: #tek tape management skemi select time.sleep(0.5) pyautogui.press('enter') else: x = content_location.x y = content_location.y pyautogui.moveTo(x +100,y, duration = 0.8) pyautogui.click(x +100,y) pyautogui.moveTo(x+100 ,y+30, duration = 0.3) pyautogui.click(x+100,y+30) time.sleep(0.3) pyautogui.press('enter') time.sleep(1) pyautogui.press('enter') #per rastin e e fundit qe del tabele, ne rastet e tjera enter ska funksion explorer_reports() time.sleep(0.5) #smooth transition nga explorer te dpm pyautogui.getActiveWindow().close() pyautogui.alert(folder_location, 'folder location')
def cria_site_v1(write, qtd_text): from concurrent.futures import ThreadPoolExecutor from time import sleep import pyautogui as pygui import os """ :param write: lista q vai ser escrita no arquivo html :return: True p/ criar Arquivo, False para não """ import re # write_find = [m.start() for m in re.finditer('.notaCancelada', str(write))] tables = write_find = [ m.start() for m in re.finditer('<table', str(write)) ] # input(f'MAX-VALUE NO FILE->{write_find}') len_tables = len(tables) # if len(write_find) > 0: # -> legal, mas não vou conseguir usar, vou ter que exportar todos pois pode ser que todos tenham print("retornando tupla se True...") if True: from time import sleep from os import system s = 'new-site.html' site = open(s, 'w') site.write(write) site.close() executors_list = [] with ThreadPoolExecutor(max_workers=5) as executor: executors_list.append(executor.submit(system, 'new-site.html')) sleep(2) # pygui.click(1900, 1000) # pygui.drag(-1900, -1000, duration=.5) x, y = pygui.position() # ou então pygui append hotkey ('control', 'a') executors_list.append( executor.submit(pygui.getActiveWindow().maximize)) sleep(2) executors_list.append( executor.submit(pygui.click, pygui.getActiveWindow().centerx, pygui.getActiveWindow().centery)) executors_list.append( executor.submit(pygui.hotkey, 'ctrl', 'a', interval=.2)) sleep(2) print('holy') # executors_list.append(executor.submit(pygui.click, x, y)) executors_list.append(executor.submit(pygui.hotkey, 'ctrl', 'c')) # sleep(.2) # executors_list.append(executor.submit(pygui.click, x, y)) sleep(2) executors_list.append( executor.submit(pygui.click, pygui.position())) # executors_list.append(executor.submit(pygui.hotkey, 'ctrl', 'f')) executors_list.append(executor.submit(pygui.hotkey, 'ctrl', 'w')) return True, len_tables
# goto command if additionalCommand == 'goto' and arg is not None: auto.write("cd " + arg, interval=interval_writing) auto.press('enter') # Write if additionalCommand == 'write' and arg is not None: auto.write(arg, interval=interval_writing) if __name__ == '__main__': interval_writing = 0.018 print(codePath) auto.sleep(0.5) # Get Active terminal fw = auto.getActiveWindow() fw.maximize() auto.hotkey('alt', 'shift', '-', interval=interval_writing) auto.hotkey('alt', 'shift', '-', interval=interval_writing) auto.hotkey('alt', 'up', interval=interval_writing) auto.hotkey('alt', 'up', interval=interval_writing) auto.hotkey('alt', 'shift', '-', interval=interval_writing) auto.hotkey('alt', 'up', interval=interval_writing) auto.hotkey('alt', 'shift', '+', interval=interval_writing) auto.hotkey('alt', 'down', interval=interval_writing) auto.hotkey('alt', 'shift', '+', interval=interval_writing)
import pyautogui as p p.hotkey('win', 'r') p.typewrite('notepad') p.press('enter') p.typewrite('Oi! Eu sou um bot') valor = p.getActiveWindow() valor.close() p.press('enter') p.typewrite('Robo01') p.press('enter')
import pyautogui fw = pyautogui.getActiveWindow() # 현재 활성화된 창 (VSCode) print(fw.title) # 창의 제목 정보 print(fw.size) # 창의 크기 정보 (width, height) print(fw.left, fw.top, fw.right, fw.bottom) # 창의 좌표 정보 pyautogui.click(fw.left + 25, fw.top + 20) for w in pyautogui.getAllWindows(): print(w) # 모든 윈도우 가져오기
def analyze(): pic_folder = pathlib.Path('../figures/combinedorbit2') pics = os.listdir(pic_folder) pic_paths = [os.path.join(pic_folder, pic) for pic in pics] pic_date_format = int( input( 'What is the format for the date in the pictures?\n 1 - "Year-DOYTHour", 2 - "YearDOY_HourMinute"\n ' )) naming_format = { 1: { 'size': [-15, -4], 'format': '%Y-%jT%H' }, 2: { 'size': [-16, -4], 'format': '%Y%j_%H%M' } } date_format_index = naming_format[pic_date_format]['size'] date_strip_format = naming_format[pic_date_format]['format'] start_date = str( input( 'What date(Y-M-DTH) would you like to start with?\nTo start from the beginning picture press Enter - ' )) if start_date == '': pic_num = 0 else: start_date_doy = datetime.datetime.strptime(start_date, '%Y-%m-%dT%H') print(start_date_doy) for num, pic in enumerate(pic_paths): if datetime.datetime.strptime( pic[date_format_index[0]:date_format_index[1]], date_strip_format) == start_date_doy: pic_num = num print(num) break time_list = [] pos_list = [0] for i in range(0, 21600 + 1): time_list.append( datetime.datetime(1998, 6, 1, 0) + datetime.timedelta(seconds=i)) for i in range(1, len(time_list)): pos_list.append(i / len(time_list)) time_list_6 = [ time_list[i].hour + time_list[i].minute / 60 + time_list[i].second / 3600 for i in range(len(time_list)) ] time_list_12 = [i + 6 for i in time_list_6] time_list_18 = [i + 6 for i in time_list_12] time_list_24 = [i + 6 for i in time_list_18] p = subprocess.Popen( ["C:\Program Files\Honeyview\Honeyview.exe", pic_paths[pic_num]]) print('please specify graph area') print('leftmost x-axis portion') mouse.wait('left') pos = pyautogui.position() graph_area = [pos.x] time.sleep(.5) print('rightmost x-axis portion') mouse.wait('left') pos = pyautogui.position() graph_area.append(pos.x) time.sleep(.4) print('Graph area defined') while True: #Sheath to Sphere using nums? if keyboard.is_pressed('esc'): p.kill() break if keyboard.is_pressed('3'): print('Select new graph area') print('leftmost x-axis portion') mouse.wait('left') pos = pyautogui.position() graph_area = [pos.x] time.sleep(.5) print('rightmost x-axis portion') mouse.wait('left') pos = pyautogui.position() graph_area.append(pos.x) time.sleep(.1) print('Graph area defined') if mouse.is_pressed('left'): win = pyautogui.getActiveWindow() mouse_pos = pyautogui.position() graph_len = graph_area[1] - graph_area[0] if mouse_pos.x >= graph_area[ 1] and mouse_pos.x <= win.left + win.width: print('Next image') pic_num += 1 p.kill() p = subprocess.Popen([ "C:\Program Files\Honeyview\Honeyview.exe", pic_paths[pic_num] ]) time.sleep(0.5) elif mouse_pos.x >= win.left and mouse_pos.x <= graph_area[0]: print('Previous image') pic_num -= 1 p.kill() p = subprocess.Popen([ "C:\Program Files\Honeyview\Honeyview.exe", pic_paths[pic_num] ]) time.sleep(0.5) if mouse_pos.x >= graph_area[0] and mouse_pos.x <= graph_area[1]: print( 'Would you like to record this point as a crossing? Press 1 for yes and 2 for no' ) while True: if keyboard.is_pressed('1'): record = True print('Yes') break elif keyboard.is_pressed('2'): record = False print('No') break if record: pass elif not record: continue time.sleep(0.6) mouse_rel_pos = (mouse_pos.x - graph_area[0]) / graph_len date_time_stamp = datetime.datetime.strptime( pic_paths[pic_num] [date_format_index[0]:date_format_index[1]], date_strip_format) record_date = date_time_stamp.date() closest_pos = min( range(len(pos_list)), key=lambda j: abs(pos_list[j] - mouse_rel_pos)) if date_time_stamp.hour == 0: graph_time_stamp = time_list_6[closest_pos] elif date_time_stamp.hour == 6: graph_time_stamp = time_list_12[closest_pos] elif date_time_stamp.hour == 12: graph_time_stamp = time_list_18[closest_pos] elif date_time_stamp.hour == 18: graph_time_stamp = time_list_24[closest_pos] print( 'What type of crossing is this? 1-To sheath 2-To magnetosphere' ) while True: if keyboard.is_pressed('1'): record_type = 'Sheath' break elif keyboard.is_pressed('2'): record_type = 'Magnetosphere' break temp_hr = int(graph_time_stamp) temp_min = int((graph_time_stamp * 60) % 60) temp_sec = int((graph_time_stamp * 3600) % 60) record_time = datetime.datetime.strptime( f'{temp_hr}:{temp_min}:{temp_sec}', '%H:%M:%S').time() print( f'{record_type} crossing at {record_date} {record_time} recorded.' ) with open('jno_crossings.dat', 'a') as crossing: crossing.writelines( f'\n{record_date},{record_time},{record_type}') crossing.close() print('Continue analyzing images')