def send_command(self, cmd): self.save_screenshot() pyautogui.hotkey('ctrl', 'space') pyautogui.typewrite(cmd) self.save_screenshot() pyautogui.press('enter') pyautogui.press('escape')
def episode_gp(): pya.hotkey('alt', 'a') pya.typewrite(['tab'] * 4, interval=0.1) gp = pyperclip.copy('empty') pya.hotkey('ctrl', 'c') gp = pyperclip.paste() return gp
def cut(link, FolderName): global UserName global Password global WaitTime global ChromiumBinary global UserNameLocation global PasswordLocation global PrepdButtonLocation global FolderSelectLocation global CatchButtonLocation global FirstBool print "Link: " + link print "Folder Name: " + FolderName + "\n" Popen([ChromiumBinary, "--incognito", link]) print "went to rss link" time.sleep(WaitTime) pyautogui.moveTo(PrepdButtonLocation[0], PrepdButtonLocation[1]) pyautogui.click() print "clicked on prepd button" time.sleep(WaitTime) if FirstBool == True: #login time.sleep(WaitTime) pyautogui.moveTo(PasswordLocation[0], PasswordLocation[1]) pyautogui.click() pyautogui.typewrite(Password, interval=0.05) print "typed password" pyautogui.moveTo(UserNameLocation[0], UserNameLocation[1]) pyautogui.click() pyautogui.typewrite(UserName, interval=0.05) print "typed username" pyautogui.press('enter') print "logged in" time.sleep(WaitTime) pyautogui.moveTo(FolderSelectLocation[0], FolderSelectLocation[1]) pyautogui.click() print "clicked on folder selection" pyautogui.typewrite(FolderName, interval=0.05) pyautogui.press('enter') print "typed into folder selection" pyautogui.moveTo(CatchButtonLocation[0], CatchButtonLocation[1]) pyautogui.click() time.sleep(WaitTime) print "caught article" pyautogui.press("esc") pyautogui.hotkey('ctrl', 'w') print "closed tab\n"
def episode_get_mcn_and_ref(): # get mcn mcn = pyperclip.copy('na') pya.moveTo(424, 474, duration=0.1) pya.dragTo(346, 474, duration=0.1) pya.hotkey('ctrl', 'c') mcn = pyperclip.paste() pya.moveTo(424, 474, duration=0.1) pya.click(button='right') pya.moveTo(481, 268, duration=0.1) pya.click() mcn = pyperclip.paste() mcn = mcn.replace(' ', '') # get ref ref = pyperclip.copy('na') pya.moveTo(500, 475, duration=0.1) pya.dragRel(-8, 0, duration=0.1) pya.hotkey('ctrl', 'c') ref = pyperclip.paste() pya.moveRel(8, 0, duration=0.1) pya.click(button='right') pya.moveTo(577, 274, duration=0.1) pya.click() ref = pyperclip.paste() return mcn, ref
def quoteOSHPark(self): """Function for navigating OSHPark's website.""" url, user, pw = self.readConfig('oshpark', 'rigid') # Open new tab and go to URL self.newTab() self.driver.get(url) # Enter login information self.driver.find_element_by_css_selector('#user_email').send_keys(user) self.driver.find_element_by_css_selector('#user_password').send_keys(pw) # Click login button self.driver.find_element_by_css_selector('.buttons > input:nth-child(1)').click() self.driver.find_element_by_css_selector('#ember291').click() self.driver.find_element_by_css_selector('#file_selector > input:nth-child(2)').click() e = EWMH() windows = e.getClientList() for window in windows: if e.getWmName(window) == 'File Upload': time.sleep(0.5) e.setActiveWindow(window) e.display.flush() time.sleep(0.5) pyautogui.hotkey('ctrl', 'a') pyautogui.press('backspace') # '''get file location from config file''' # pyautogui.typewrite(fileLocation) pyautogui.press('return')
def printscores(): #note only works in Firefox #selects all of the scores try: selectall = WebDriverWait(browser, 3).until(EC.presence_of_element_located((By.ID, "m_m_mid_mid_ReportByDate2_rptDataView_ctl00_ctl02_ctl01_GridClientSelectColumnSelectCheckBox"))) selectall.click() except: pass #exports to pdf export = WebDriverWait(browser, 2).until(EC.presence_of_element_located((By.ID, "m_m_top_wel_imgBtnExport"))) export.click() logging.debug("Still working") #chooses pdf from the popup browser.switch_to.frame('rwPreview') choosepdf = WebDriverWait(browser, 2).until(EC.presence_of_element_located((By.ID, "radio4"))) choosepdf.click() donebutton = browser.find_element_by_id('imgBtnDone') donebutton.click() #todo let it continue when the pdf downloads and break if it does not download time.sleep(5) pyautogui.press('enter') time.sleep(2) pyautogui.hotkey('ctrl', 'j') time.sleep(2) pyautogui.press('enter') time.sleep(4) pyautogui.hotkey('ctrl', 'p') time.sleep(4) pyautogui.press('enter') time.sleep(4) pyautogui.typewrite(printcode) pyautogui.press('enter')
def FillinExcelxCV1(): # Close current edit area xCloseN=(399,200) pyautogui.moveTo(xCloseN) time.sleep(0.25) pyautogui.click() time.sleep(0.1) # Back to Excel xExcel=(337,746) xExcelDown=(1356,670) xCellEditC=(267,238) pyautogui.moveTo(xExcel) time.sleep(0.25) pyautogui.click() time.sleep(0.5) # Move and Paste in C pyautogui.moveTo(xCellEditC) time.sleep(0.25) pyautogui.click() time.sleep(0.1) pyautogui.hotkey('ctrl','v') time.sleep(0.1) pyautogui.hotkey('ctrl','s') #Save Excel time.sleep(1.5) pyautogui.moveTo(xExcelDown) time.sleep(0.25) pyautogui.click() time.sleep(0.5)
def loadSymbolInChart(msComponents, symbol): pyautogui.moveTo(msComponents['symbolEntry']['x'], msComponents['symbolEntry']['y'], 0.25) safeClick(msComponents['symbolEntry']['x'], msComponents['symbolEntry']['y']) pyautogui.hotkey(platform.primary_key_modifier, 'a') pyautogui.press('delete') pyautogui.typewrite(symbol) pyautogui.typewrite(['enter']) wait(DELAY_CHART_LOAD)
def switchTabWindow(self, direction): #left = 0, right = 1 if direction == 0: pag.hotkey('command', 'shift', '[') elif direction == 1: pag.hotkey('command', 'shift', ']') else: assert direction == 0 or direction == 1, "Actor::switchWindow: wrong direction"
def perform_action(self, clazz): if clazz == 'flip': pyautogui.hotkey('command', 'space') elif clazz == 'top_down': pyautogui.press('space') elif clazz == 'right_left': pyautogui.press('right') print "dummy"
def switchDesktop(self, direction): #left = 0, right = 1 if direction == 0: pag.hotkey('ctrl', 'left') elif direction == 1: pag.hotkey('ctrl', 'right') else: assert direction == 0 or direction == 1, "Actor::switchDesktop: wrong direction"
def get_title(): pya.hotkey('alt', 't') title = pyperclip.copy('na') pya.moveTo(190, 135, duration=0.1) pya.click(button='right') pya.moveRel(55, 65) pya.click() title = pyperclip.paste() return title
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 pass_search(): pyautogui.PAUSE = 0.5 pyautogui.FAILSAFE = False pyperclip.copy("") dondeEstaElBoton = pyautogui.locateOnScreen("go-button.png") if dondeEstaElBoton is None: print "El boton de GO no fue encontrado" else: botonPos = list(dondeEstaElBoton) print botonPos centroBoton = pyautogui.center(botonPos) print centroBoton contador = 0 while True: contador += 1 pyautogui.moveTo(centroBoton) pyautogui.moveRel(796, 0) # Mover el raton a la barra de desplazamiento pyautogui.click(None, None, 2) # if contador == 1: # time.sleep(0.3) # pyautogui.typewrite('!reset') # pyautogui.press('enter') pyautogui.click(None, None, 1) pyautogui.dragRel(0, -293, 1, button="left") # pyautogui.scroll(10) #Hacer scroll para llegar a la parte superior del cuadro de texto # pyautogui.moveRel(0, -294) #Mover el raton a la parte superior de la barra de desplazamiento pyautogui.moveRel(-390, 0) # Mover el raton a la posicion en donde se encuentra la clave pyautogui.PAUSE = 0.05 pyautogui.click(None, None, 2) # pyautogui.doubleClick() #Hacer dobleclic en la palabra de la clave pyautogui.hotkey("ctrl", "c") # pyautogui.doubleClick() #Hacer dobleclic en la palabra de la clave # pyautogui.hotkey('ctrl', 'c') # pyautogui.doubleClick() #Hacer dobleclic en la palabra de la clave # pyautogui.hotkey('ctrl', 'c') pyautogui.PAUSE = 1 r = pyperclip.paste() print r if len(r) == 10: print "clave encontrada" break if contador == 5: print "Se hizo el intento 5 veces para buscar la clave" break time.sleep(0.5)
def typeAndSave(self, msg): """ A matching keystroke is sent for each character in msg. Afterwards, ctrl+s is sent. """ keys = list(msg) + ["enter"] pyautogui.typewrite(keys, interval=0.05) pyautogui.hotkey("ctrl", "s") time.sleep(1)
def do_action(action): print action if "url" in action: handle_url_action(action) if "media" in action or "volume" in action: handle_media_keys(action) if "screen" in action: handle_screen(action) keys = action.lower().split('_') pyautogui.hotkey(*keys)
def scene(key, name, time, lock): pyautogui.hotkey('winleft', 'alt', 'shift', str(key), interval=0.1) stoptimer() global timer if lock: name = name + ' Locked' timer = count_down('Scene: '+name+' (', time) timer.start() if lock: time.sleep(time)
def gmail(self): ''' Starts Firefox. Navigates to Gmail. ''' startfile(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe') sleep(5) hotkey('ctrl','l') sleep(2) typewrite('www.gmail.com') press('enter') sleep(2)
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 close_out(anaesthetist): """Close patient file with mouse click and display billing details if a billing anaesthetist.""" time.sleep(1) pya.moveTo(x=780, y=90) pya.click() time.sleep(1) pya.hotkey('alt', 'n') pya.moveTo(x=780, y=110) if anaesthetist in nc.BILLING_ANAESTHETISTS: webbrowser.open( 'd:\\Nobue\\report_{}.html'.format(anaesthetist.split()[-1]))
def pyautogui_add_one_file(full_path): if full_path: pyperclip.copy(full_path) pyautogui.press('down') i = 1 while i < 9: i += 1 pyautogui.press('tab') pyautogui.hotkey('ctrl', 'v') pyautogui.press('enter') pyautogui.press('enter')
def episode_theatre(endoscopist, nurse, clips, varix_lot): pya.hotkey('alt', 'n') pya.typewrite(['left'] * 2) # if not pya.pixelMatchesColor(1100, 100, (240, 240, 240)): # pya.hotkey('ctrl', 'f1') # time.sleep(0.5) user = os.getenv('USERNAME') doc_coord = coords.get(user, ((100, 155), (100, 360)))[0] pya.moveTo(doc_coord) pya.click() pya.press('tab') doc_test = pyperclip.copy('empty') pya.hotkey('ctrl', 'c') doc_test = pyperclip.paste() if doc_test == 'Endoscopist': pya.press('tab') pya.typewrite(['enter'] * 2) pya.moveRel(400, 0) pya.click() pya.typewrite(['tab'] * 2) pya.typewrite(['enter'] * 2) pya.moveTo(doc_coord) pya.click() pya.typewrite(endoscopist) pya.typewrite(['enter', 'e', 'enter']) pya.moveRel(400, 0) pya.click() pya.typewrite(nurse) pya.typewrite(['enter', 'e', 'enter']) if clips != 0 or varix_lot: pros_coord = coords.get(user, ((100, 155), (100, 360)))[1] pya.moveTo(pros_coord) pya.click() if varix_lot: pyperclip.copy('Boston Scientific Speedband Superview Super 7') pya.hotkey('ctrl', 'v') pya.press('enter') time.sleep(0.5) pyperclip.copy(varix_lot) pya.hotkey('ctrl', 'v') pya.press('enter') pya.typewrite(['tab'] * 2) if clips != 0: pyperclip.copy('M00521230') for i in range(clips): pya.typewrite(['b', 'enter']) time.sleep(0.5) pya.hotkey('ctrl', 'v') pya.press('enter') pya.typewrite(['tab'] * 2)
def save_file(): print('KEYBOARD: Ctrl + s') keyboard.hotkey('ctrl', 's') time.sleep(1) now = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") current_path = os.path.dirname(os.path.realpath(__file__)) output_path = current_path + os.sep + 'output' + os.sep file_name = 'temp_data_' + now + '.txt' file_path = output_path + file_name print('save file as', file_path) keyboard.typewrite(file_path) keyboard.typewrite(['tab', 'down','down','enter','enter']) return file_path
def handle_url_action(action): print action if action == "urlstore": pyautogui.hotkey("command", "l") pyautogui.hotkey("command", "c") url = check_output(["osascript", "-e", "the clipboard"]) print url setUrl(url) elif action == "urlfetch": url = getUrl() # check_output(["osascript", "-e", 'set the clipboard to "%i"' % url]) if url != None and len(url) != 0: check_output(["open", url])
def fillTown(town): pyautogui.typewrite(town) time.sleep(0.7) pyautogui.hotkey('down') pyautogui.hotkey('down') pyautogui.hotkey('tab') pyautogui.hotkey('tab')
def login(loginId,membership_pass,trading_pass): "loginId, membership_pass and trading_pass are strings to be passed " pyautogui.hotkey('ctrl','l') time.sleep(1) pyautogui.click(740,340) # click on login id field pyautogui.typewrite(loginId) pyautogui.typewrite('\t') time.sleep(0.25) pyautogui.typewrite('\t') pyautogui.typewrite(membership_pass) pyautogui.typewrite('\t') pyautogui.typewrite(trading_pass) pyautogui.press('enter') time.sleep(30)
def dumper(): pya.click(100, 500) pya.hotkey('alt', 'd') pya.press('enter') pya.hotkey('alt', 'd') mrn = pyperclip.copy('empty') pya.hotkey('ctrl', 'c') mrn = pyperclip.paste() print(mrn) today_path = write_as_billed(mrn) make_web_secretary(today_path) with shelve.open('d:\\JOHN TILLET\\episode_data\\dumper_data.db') as s: try: episode = s[mrn] except KeyError: pya.alert('No data available') return episode_discharge( episode['in_theatre'], episode['out_theatre'], episode['anaesthetist'], episode['endoscopist']) episode_procedures( episode['upper'], episode['colon'], episode['banding'], episode['asa']) if (episode['upper'] in {'30490-00'} or 'HALO' in episode['message'] or '32089-00' in episode['message'] or episode['colon'] in {'32093-00', '32094-00'} or episode['banding'] in {'32153-00'}): episode_claim() else: pya.hotkey('alt', 'c') episode_theatre(episode['endoscopist'], episode['nurse'], episode['clips'], episode['varix_lot'])
def qq_bottle(): i=0 count = 100 while i <count: pag.moveTo(392, 377) pag.click() time.sleep(1) pag.hotkey('ctrl', 'v') # pag.typewrite('今年年终奖没有了,有点失落,想和你聊天,可以加Q么,', interval=0.05) pag.moveTo(1278,749) time.sleep(1) pag.hotkey('ctrl', 'enter') # pag.click() i+=1
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 episode_theatre(endoscopist, nurse, clips, varix_lot): pya.hotkey('alt', 'n') pya.typewrite(['left'] * 2, interval=0.1) doc_coord = (100, 155) pya.moveTo(doc_coord) pya.click() pya.press('tab') doc_test = pyperclip.copy('empty') pya.hotkey('ctrl', 'c') doc_test = pyperclip.paste() if doc_test == 'Endoscopist': pya.press('tab') pya.typewrite(['enter'] * 2, interval=0.1) pya.moveRel(400, 0) pya.click() pya.typewrite(['tab'] * 2, interval=0.1) pya.typewrite(['enter'] * 2, interval=0.1) pya.moveTo(doc_coord) pya.click() pya.typewrite(endoscopist) pya.typewrite(['enter', 'e', 'enter'], interval=0.1) pya.moveRel(400, 0) pya.click() pya.typewrite(nurse) pya.typewrite(['enter', 'e', 'enter'], interval=0.1) if clips != 0 or varix_lot: pya.moveTo(100, 360) pya.click() if varix_lot: pyperclip.copy('Boston Scientific Speedband Superview Super 7') pya.hotkey('ctrl', 'v') pya.press('enter') time.sleep(0.5) pyperclip.copy(varix_lot) pya.hotkey('ctrl', 'v') pya.press('enter') pya.typewrite(['tab'] * 2, interval=0.1) if clips != 0: pyperclip.copy('M00521230') for i in range(clips): pya.typewrite(['b', 'enter'], interval=0.2) time.sleep(0.5) pya.hotkey('ctrl', 'v') pya.press('enter') pya.typewrite(['tab'] * 2, interval=0.1)
def insert_text(text_to_insert): pyautogui.hotkey('ctrl', 'a') pyautogui.keyDown('backspace') pyautogui.keyUp('backspace') pyautogui.write(text_to_insert)
def send_tabs(number_of_tabs): for i in range(0, number_of_tabs): pyautogui.hotkey('tab')
# Recursos necessários para a importação: import pyautogui pyautogui.alert("A automação será realizada.") pyautogui.PAUSE = 2.0 pyautogui.press('winleft') pyautogui.PAUSE = 5.0 pyautogui.write('Opera GX') pyautogui.PAUSE = 2.0 pyautogui.press('enter') pyautogui.PAUSE = 5.0 pyautogui.write('https://www.youtube.com') pyautogui.PAUSE = 1.0 pyautogui.press('enter') pyautogui.PAUSE = 2.0 pyautogui.hotkey('winleft', 'd') pyautogui.PAUSE = 1.0 pyautogui.moveTo(x=1323, y=742) pyautogui.click(x=1323, y=742) pyautogui.PAUSE = 5.0 pyautogui.alert("Automação finalizada.") #Comando que mostra os nomes das letras do teclado na biblioteca PyAutoGui. #print(pyautogui.KEYBOARD_KEYS)
def search(param): pyautogui.hotkey('win', 's') pyautogui.typewrite(param, interval=0.5) pyautogui.typewrite(['enter'])
ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)) GetWindowText = ctypes.windll.user32.GetWindowTextW GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW IsWindowVisible = ctypes.windll.user32.IsWindowVisible titles = [] def foreach_window(hwnd, lParam): if IsWindowVisible(hwnd): length = GetWindowTextLength(hwnd) buff = ctypes.create_unicode_buffer(length + 1) GetWindowText(hwnd, buff, length + 1) titles.append((hwnd, buff.value)) return True EnumWindows(EnumWindowsProc(foreach_window), 0) icentra = [] for i in range(len(titles)): if "PowerChart" in titles[i][1]: icentra += titles[i] handle = icentra[0] title = icentra[1] win32gui.SetForegroundWindow(find_window(title=title)) pyautogui.hotkey('ctrl', 'a')
import time import pyautogui import serial ArduinoSerial = serial.Serial('COM8', 9600) prev ='z' while True: x = ArduinoSerial.readline().decode('ascii') print(x) # l="abcdefghij" if "L" in x: pyautogui.hotkey('pgup') print(x) elif "R" in x: print(x) pyautogui.hotkey('pgdwn') elif (x < prev): pyautogui.hotkey('up') # pyautogui.hotkey('up') # pyautogui.hotkey('up') pyautogui.hotkey('up') print("l") elif(prev < x): # pyautogui.hotkey('down') # pyautogui.hotkey('down') pyautogui.hotkey('down') pyautogui.hotkey('down') print("r") prev = x
h_move = 0 v_move = 0 while timer < 50: delay = 0 try: s = ser.readline() if "CMD1" in s: print("<tilt_backward>") pyautogui.typewrite(['up']) elif "CMD9" in s: print("<tilt_forward>") pyautogui.typewrite(['down']) elif "CMD2" in s: print("<tilt_right>") pyautogui.hotkey('alt', 'tab') #if v_move == 0: # v_move = 1 #else: # v_move = 0 elif "CMD8" in s: print("<tilt_left>") pyautogui.hotkey('win', 'tab') #if v_move == 0: # v_move = -1 #else: # v_move = 0 elif "CMD3" in s: print("<tilt_ccw") pyautogui.typewrite(['left']) #if h_move == 0:
def showWareDocButton(): pyautogui.hotkey('shift', 'f7')
# this is a source code import pyautogui # run some program pyautogui.hotkey('win', 'r') # mspaint pyautogui.typewrite('mspaint') pyautogui.press('enter') # wait for a while pyautogui.moveRel(1, 1, 1) # maximize the window pyautogui.hotkey('win', 'up') # 選三角形 pyautogui.moveTo(499, 65, 0.5) pyautogui.click() # 選填滿 pyautogui.click(560, 83) pyautogui.moveTo(551, 136, 0.5) pyautogui.click() # 選顏色 pyautogui.click(691, 69) pyautogui.click(897, 82) pyautogui.click(733, 69) pyautogui.click(897, 82)
if lookImageCheck("./completelyPicked.png"): pyautogui.press('esc') sleep(0.5) pyautogui.press('esc') sleep(1) nextbuttoncheck = nextButtonCheck() if not nextbuttoncheck: nextButton() else: counter = 0 innerLoop = False waitForWindow('Warehouse Shipment') print('about to create pick') createPickButton() sleep(1) pyautogui.hotkey('ctrl', 'enter') sleep(1) pyautogui.press('enter') pickLinesButton() waitForWindow('Warehouse Activity') cardButton() waitForWindow('Warehouse Pick') quantityButton() registerButton() sleep(1) if lookImageCheck("./yesButton.png"): pyautogui.press('left') sleep(timeInterval) pyautogui.press('enter') sleep(timeInterval) elif lookImageCheck("./noBin.png"):
def releaseButton(): pyautogui.hotkey('ctrl', 'f9')
import serial import time import pyautogui ser = serial.Serial('COM3', 9600) time.sleep(3) pyautogui.hotkey('alt', 'win', 'r') while 1: val = str(ser.readline()) if 'Scroll_Up' in val: pyautogui.typewrite(['up']) print(val) if 'Scroll_Down' in val: pyautogui.typewrite(['down']) print(val) if 'Forward' in val: pyautogui.typewrite(['browserforward']) print(val) if 'Rewind' in val: pyautogui.typewrite(['browserback']) print(val) if 'Change_Tab' in val: pyautogui.hotkey('ctrl', 'tab') print(val)
def robbot(category, title, text, price, traffic): # OSの確認 ctr = os_check.use_os() # 現在のurl取得 url = url_check.url_check() # 初期ポジ logging.info('info %s %s', 'ヤフオクへ画像データをインポート', 'Start') pyautogui.moveTo(1, 1, duration=0) time.sleep(0.3) # データの場所に行く pyautogui.moveTo(985, 115, duration=0) time.sleep(0.3) pyautogui.dragTo(500, 700, 0.3, button='left') logging.info('info %s %s', 'ヤフオクへ画像データをインポート', 'End') # いったんスクロール logging.info('info %s %s', '商品タイトル記入', 'Start') time.sleep(0.3) pyautogui.vscroll(-10) # 商品名へ移動 time.sleep(0.3) pyautogui.moveTo(50, 500, duration=0) # クリックして商品名記入 time.sleep(0.3) pyautogui.click() time.sleep(0.3) pyautogui.click() # テキスト記入 time.sleep(0.3) pyperclip.copy(title) time.sleep(0.3) pyautogui.hotkey(ctr, 'v') time.sleep(0.3) logging.info('info %s %s', '商品タイトル記入', 'End') # いったん下でポジションをとる pyautogui.vscroll(-3000) logging.info('info %s %s', '商品テキスト入力', 'End') time.sleep(0.2) pyautogui.vscroll(25) logging.info('info %s %s', '値段', 'Start') # 値段入力 time.sleep(0.3) pyautogui.moveTo(50, 590, duration=0) time.sleep(0.3) pyautogui.click() pyperclip.copy(price) time.sleep(0.3) pyautogui.hotkey(ctr, 'a') time.sleep(0.3) pyautogui.hotkey(ctr, 'v') # 即決価格設定 url = url_check.url_check_t(url) time.sleep(0.3) pyautogui.moveTo(50, 640, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(0.3) pyautogui.moveTo(50, 680, duration=0) time.sleep(0.3) pyautogui.click() decision_price = str(int(price) + 200) pyperclip.copy(decision_price) time.sleep(0.3) pyautogui.hotkey(ctr, 'a') time.sleep(0.3) pyautogui.hotkey(ctr, 'v') logging.info('info %s %s', '値段', 'End') logging.info('info %s %s', '日時設定', 'Start') # 終了する日時 time.sleep(0.3) pyautogui.vscroll(-10) time.sleep(0.3) pyautogui.moveTo(50, 450, duration=0) # 540 time.sleep(0.3) pyautogui.click() time.sleep(0.2) pyautogui.moveTo(50, 400, duration=0) time.sleep(0.2) pyautogui.click() time.sleep(0.1) pyautogui.moveTo(50, 450, duration=0) time.sleep(0.2) pyautogui.click() time.sleep(0.2) pyautogui.moveTo(50, 420, duration=0) time.sleep(0.2) pyautogui.click() time.sleep(0.2) logging.info('info %s %s', '日時設定', 'End') pyautogui.vscroll(60) logging.info('info %s %s', '商品テキスト入力', 'Start') pyautogui.moveTo(190, 650, duration=0) time.sleep(0.2) pyautogui.click() time.sleep(0.2) pyautogui.click() pyperclip.copy(text) time.sleep(0.2) pyautogui.hotkey(ctr, 'v') time.sleep(0.2) pyautogui.moveTo(650, 320, duration=0) time.sleep(0.1) pyautogui.click() pyautogui.vscroll(10) logging.info('info %s %s', '商品テキスト入力', 'End') # url確認 url = url_check.url_check_t(url) time.sleep(0.1) pyautogui.vscroll(-20) # カテゴリ選択へ logging.info('info %s %s', 'カテゴリチェック', 'Start') pyautogui.moveTo(50, 650, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(5) url = url_check.url_check_f(url) # カテゴリ検索へ pyautogui.moveTo(140, 630, duration=0) # クリックして商品名記入 time.sleep(0.3) pyautogui.click() time.sleep(0.3) pyautogui.click() time.sleep(0.3) pyperclip.copy(category) time.sleep(0.3) #以下のコマンドmacとwinで分ける必要がある。 # 以下mac time.sleep(0.3) pyautogui.hotkey(ctr, 'a') time.sleep(0.3) pyautogui.hotkey(ctr, 'v') # 以下win # pyautogui.hotkey('ctr', 'v') time.sleep(0.3) # 検索ボタンへ移動クリック pyautogui.moveTo(800, 630, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(0.3) # スクロール pyautogui.vscroll(-8) time.sleep(0.2) # カテゴリを選択 pyautogui.moveTo(70, 630, duration=0) time.sleep(0.2) pyautogui.click() time.sleep(0.3) pyautogui.moveTo(30, 585, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(0.3) pyautogui.vscroll(-100) time.sleep(0.3) url = url_check.url_check_t(url) pyautogui.moveTo(550, 575, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(0.2) url = url_check.url_check_f(url) time.sleep(0.2) pyautogui.moveTo(550, 575, duration=0) time.sleep(0.3) pyautogui.click() pyautogui.vscroll(-3000) time.sleep(0.3) pyautogui.moveTo(480, 690, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(5) logging.info('info %s %s', '同意画面', 'Start') url = url_check.url_check_f(url) time.sleep(0.3) pyautogui.moveTo(318, 470, duration=0) time.sleep(0.2) pyautogui.click() time.sleep(0.2) pyautogui.moveTo(470, 525, duration=0) time.sleep(0.2) pyautogui.click() logging.info('info %s %s', '同意画面', 'End') logging.info('info %s %s', '出品完了画面', 'Start') time.sleep(7) pyautogui.moveTo(40, 360, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(3) pyautogui.moveTo(60, 160, duration=0) logging.info('info %s %s', '出品完了画面', 'End') logging.info('info %s %s', 'メインページバック', 'Start') time.sleep(0.3) pyautogui.vscroll(3000) time.sleep(0.3) pyautogui.moveTo(80, 160, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(2) url = url_check.url_check_f(url) pyautogui.moveTo(570, 170, duration=0) time.sleep(5) pyautogui.click() time.sleep(0.3) pyautogui.hscroll(-3000) time.sleep(0.3) pyautogui.moveTo(740, 220, duration=0) time.sleep(0.3) pyautogui.click() logging.info('info %s %s', 'メインページバック', 'End') # 下書き削除 time.sleep(5) logging.info('info %s %s', '下書き削除', 'Start') pyautogui.moveTo(60, 500, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(0.3) pyautogui.hscroll(-3000) time.sleep(0.3) pyautogui.moveTo(740, 600, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(0.3) pyautogui.moveTo(480, 500, duration=0) time.sleep(0.3) pyautogui.click() time.sleep(0.7) pyautogui.hscroll(3000) logging.info('info %s %s', '下書き削除', 'End')
import pyautogui, sys, time files_to_convert = int(input("How many files need to be converted: ")) delay = float( input("Task delay? 1 for small nests, 6 for full sheet, in seconds: ")) y_modifier = 0 pyautogui.click(x=1300, y=110) for x in range(1, files_to_convert + 1): try: # Open windows explorer pyautogui.hotkey('ctrl', 'd') x_loc = 270 y_loc = 180 + y_modifier time.sleep(0.7) print(x_loc, y_loc) # Click the next file pyautogui.doubleClick(x_loc, y_loc) time.sleep(1) # Click the generate icon generate_cut_path = pyautogui.locateCenterOnScreen('generate.png', grayscale=True) pyautogui.click(generate_cut_path) time.sleep(delay) # Keyboard hotkey for save pyautogui.hotkey('ctrl', 's') # Control + S to save nc y_modifier += 21 #could change depending on computer, 21 pixels on Forrest Desktop between files time.sleep(0.25) # Press enter to save
import pyautogui as pg import time pg.hotkey ('ctrl' , 'winleft' , 'd') pg.hotkey('winleft') pg.typewrite('chrome\n',.3) pg.hotkey('winleft','up') pg.typewrite('youtube.com\n') pg.typewrite('cute cat videos\n',.3)
def patientCardHandler(order): if order['sameday_suborder'] == 'yes': pyautogui.typewrite(orders[order['suborder_target']]['pt_num']) else: if order['sub_order'] in ('duplicate', 'changed'): pyautogui.typewrite(order['prev_ptnum']) pyautogui.typewrite(['enter']) if order['sub_order'] == 'new order': pyautogui.typewrite(['f6']) time.sleep(LAG) # ENTERING PT SEARCH, LONG DELAY # CREATING NEW CARD VIA SEARCHING # Checking to see if opening search screen has resolved count = 1 # TODO needs region to search while pyautogui.locateOnScreen(pt_search_entry) is None: print '*Pt Search Screen Scan #', count, '-Complete-' count += 1 time.sleep(2) if count == 8: order['issue_list'].append('Opening Pt Search') else: print '**Search Screen -Detected-' pyautogui.typewrite( [order['FIRSTNAMECOMPLETE'], 'tab', order['nameLast']]) # pyautogui.typewrite(['tab']) # pyautogui.typewrite(i["nameLast"]) pyautogui.hotkey('alt', 's') pyautogui.hotkey('alt', 'c') pyautogui.hotkey('alt', 's') # SEARCHING FOR PT CREATES LONG DELAY time.sleep(LAG) x = 1 found = 'no' while found == 'no': print '*New Pt Popup Search #', x x = x + 1 time.sleep(2) # To see New Pt Pop Up Dialogue box if pyautogui.locateOnScreen(pt_popup, region=(803, 457, 321, 186)) is not None: print '**Popup Detected' found = 'yes' pyautogui.typewrite(['y']) time.sleep(1) # entering pt info pyautogui.typewrite(['tab', 'tab', 'm', 'tab']) # gender time.sleep(SHORT_DELAY) pyautogui.typewrite(order["dob"]) pyautogui.typewrite(['tab']) pyautogui.typewrite(order['weight']) pyautogui.typewrite(['tab']) pyautogui.typewrite(order['shoesize']) pyautogui.typewrite(['tab']) pyautogui.typewrite(order['shoesize']) time.sleep(TIME_DELAY) if order['outgrowth'] == 'yes': pyautogui.typewrite(['down', 'space']) time.sleep(TIME_DELAY) else: pyautogui.typewrite(['down']) pyautogui.typewrite(['esc', 'return'], interval=SHORT_DELAY) pyautogui.hotkey('ctrl', 'c') order['pt_num'] = Tk().clipboard_get() print 'pt_num =', order['pt_num'] time.sleep(TIME_DELAY) if x == 5: print '*Similar Name Search' #TODO needs region to search if pyautogui.locateOnScreen(similar_ptname) is not None: found = 'yes' print '**Similar Name Assumed' order['issue_list'].append('Similar Pt Name Issue') print order['issue_list'] pyautogui.hotkey('shift', 'f5') pyautogui.typewrite(['f3', 'tab']) pyautogui.typewrite(order['FIRSTNAMECOMPLETE']) pyautogui.typewrite(['tab']) pyautogui.typewrite(order['nameLast']) pyautogui.typewrite(['tab', 'm', 'tab']) pyautogui.typewrite(order["dob"]) pyautogui.typewrite(['tab']) pyautogui.typewrite(order['weight']) pyautogui.typewrite(['tab']) pyautogui.typewrite(order['shoesize']) pyautogui.typewrite(['tab']) pyautogui.typewrite(order['shoesize']) time.sleep(TIME_DELAY) if order['outgrowth'] == 'yes': pyautogui.typewrite(['down', 'space']) time.sleep(TIME_DELAY) else: pyautogui.typewrite(['down']) pyautogui.typewrite(['esc']) time.sleep(SHORT_DELAY) pyautogui.hotkey('ctrl', 'end') time.sleep(SHORT_DELAY) pyautogui.typewrite(['return']) time.sleep(SHORT_DELAY) pyautogui.hotkey('ctrl', 'c') order['pt_num'] = Tk().clipboard_get() print 'pt_num =', order['pt_num'] time.sleep(TIME_DELAY)
def main(): # Argument parsing ################################################################# args = get_args() cap_device = args.device cap_width = args.width cap_height = args.height use_static_image_mode = args.use_static_image_mode min_detection_confidence = args.min_detection_confidence min_tracking_confidence = args.min_tracking_confidence use_brect = True # Camera preparation ############################################################### cap = cv.VideoCapture(cap_device) cap.set(cv.CAP_PROP_FRAME_WIDTH, cap_width) cap.set(cv.CAP_PROP_FRAME_HEIGHT, cap_height) # Model load ############################################################# mp_hands = mp.solutions.hands hands = mp_hands.Hands( static_image_mode=use_static_image_mode, max_num_hands=1, min_detection_confidence=min_detection_confidence, min_tracking_confidence=min_tracking_confidence, ) keypoint_classifier_R = KeyPointClassifier_R(invalid_value=8, score_th=0.4) keypoint_classifier_L = KeyPointClassifier_L(invalid_value=8, score_th=0.4) mouse_classifier = MouseClassifier(invalid_value=2, score_th=0.4) point_history_classifier = PointHistoryClassifier() # Read labels ########################################################### with open('model/keypoint_classifier/keypoint_classifier_label.csv', encoding='utf-8-sig') as f: keypoint_classifier_labels = csv.reader(f) keypoint_classifier_labels = [ row[0] for row in keypoint_classifier_labels ] with open( 'model/point_history_classifier/point_history_classifier_label.csv', encoding='utf-8-sig') as f: point_history_classifier_labels = csv.reader(f) point_history_classifier_labels = [ row[0] for row in point_history_classifier_labels ] # FPS Measurement ######################################################## cvFpsCalc = CvFpsCalc(buffer_len=3) # Coordinate history ################################################################# history_length = 16 point_history = deque(maxlen=history_length) # Finger gesture history ################################################ finger_gesture_history = deque(maxlen=history_length) mouse_id_history = deque(maxlen=40) # 靜態手勢最常出現參數初始化 keypoint_length = 5 keypoint_R = deque(maxlen=keypoint_length) keypoint_L = deque(maxlen=keypoint_length) # ========= 使用者自訂姿勢、指令區 ========= # time.sleep(0.5) # keepadd = False # ========= 按鍵前置作業 ========= mode = 0 presstime = presstime_2 = presstime_3 = presstime_4 = time.time() detect_mode = 2 what_mode = 'mouse' landmark_list = 0 pyautogui.PAUSE = 0 # ========= 滑鼠前置作業 ========= wScr, hScr = pyautogui.size() frameR = 100 smoothening = 7 plocX, plocY = 0, 0 clocX, clocY = 0, 0 mousespeed = 1.5 clicktime = time.time() # =============================== i = 0 finger_gesture_id = 0 # ========= 主程式運作 ========= while True: left_id = right_id = -1 fps = cvFpsCalc.get() # Process Key (ESC: end) key = cv.waitKey(10) if key == 27: # ESC break number, mode = select_mode(key, mode) # Camera capture ret, image = cap.read() if not ret: break image = cv.flip(image, 1) # Mirror display debug_image = copy.deepcopy(image) # Detection implementation image = cv.cvtColor(image, cv.COLOR_BGR2RGB) image.flags.writeable = False results = hands.process(image) image.flags.writeable = True # #################################################################### if results.multi_hand_landmarks is not None: for hand_landmarks, handedness in zip(results.multi_hand_landmarks, results.multi_handedness): # Bounding box calculation brect = calc_bounding_rect(debug_image, hand_landmarks) # Landmark calculation landmark_list = calc_landmark_list(debug_image, hand_landmarks) # print(landmark_list) # Conversion to relative coordinates / normalized coordinates pre_processed_landmark_list = pre_process_landmark( landmark_list) pre_processed_point_history_list = pre_process_point_history( debug_image, point_history) # Write to the dataset file logging_csv(number, mode, pre_processed_landmark_list, pre_processed_point_history_list) # 靜態手勢資料預測 hand_sign_id_R = keypoint_classifier_R( pre_processed_landmark_list) hand_sign_id_L = keypoint_classifier_L( pre_processed_landmark_list) mouse_id = mouse_classifier(pre_processed_landmark_list) # print(mouse_id) if handedness.classification[0].label[0:] == 'Left': left_id = hand_sign_id_L else: right_id = hand_sign_id_R # 手比one 觸發動態資料抓取 if right_id == 1 or left_id == 1: point_history.append(landmark_list[8]) else: point_history.append([0, 0]) # 動態手勢資料預測 finger_gesture_id = 0 point_history_len = len(pre_processed_point_history_list) if point_history_len == (history_length * 2): finger_gesture_id = point_history_classifier( pre_processed_point_history_list) # print(finger_gesture_id) # 0 = stop, 1 = clockwise, 2 = counterclockwise, 3 = move,偵測出現的動態手勢 # 動態手勢最常出現id ######################################### # Calculates the gesture IDs in the latest detection finger_gesture_history.append(finger_gesture_id) most_common_fg_id = Counter( finger_gesture_history).most_common() #滑鼠的deque mouse_id_history.append(mouse_id) most_common_ms_id = Counter(mouse_id_history).most_common() # print(f'finger_gesture_history = {finger_gesture_history}') # print(f'most_common_fg_id = {most_common_fg_id}') # 靜態手勢最常出現id ######################################### hand_gesture_id = [right_id, left_id] keypoint_R.append(hand_gesture_id[0]) keypoint_L.append(hand_gesture_id[1]) # print(keypoint_R) # deque右手的靜態id # print(most_common_keypoint_id) # 右手靜態id最大 if right_id != -1: most_common_keypoint_id = Counter(keypoint_R).most_common() else: most_common_keypoint_id = Counter(keypoint_L).most_common() # print(f'keypoint = {keypoint}') # print(f'most_common_keypoint_id = {most_common_keypoint_id}') ############################################################### # Drawing part debug_image = draw_bounding_rect(use_brect, debug_image, brect) debug_image = draw_landmarks(debug_image, landmark_list) debug_image = draw_info_text( debug_image, brect, handedness, keypoint_classifier_labels[most_common_keypoint_id[0][0]], point_history_classifier_labels[most_common_fg_id[0][0]], ) else: point_history.append([0, 0]) debug_image = draw_point_history(debug_image, point_history) debug_image = draw_info(debug_image, fps, mode, number) # 偵測是否有手勢 ######################################### if left_id + right_id > -2: if time.time() - presstime > 1: # change mode if most_common_ms_id[0][0] == 3 and most_common_ms_id[0][ 1] == 40: #Gesture six changes to the different mode print('Mode has changed') detect_mode = (detect_mode + 1) % 3 if detect_mode == 0: what_mode = 'Rest' if detect_mode == 1: what_mode = 'Keyboard' if detect_mode == 2: what_mode = 'Mouse' print(f'Current mode => {what_mode}') presstime = time.time() + 1 presstime_4 = time.time() # control keyboard elif detect_mode == 1: if time.time() - presstime_2 > 1: if time.time() - presstime_4 > 1: # 靜態手勢控制 control_keyboard(most_common_keypoint_id, 2, 'K', keyboard_TF=True, print_TF=False) control_keyboard(most_common_keypoint_id, 0, 'right', keyboard_TF=True, print_TF=False) control_keyboard(most_common_keypoint_id, 7, 'left', keyboard_TF=True, print_TF=False) control_keyboard(most_common_keypoint_id, 9, 'C', keyboard_TF=True, print_TF=False) control_keyboard(most_common_keypoint_id, 5, 'up', keyboard_TF=True, print_TF=False) control_keyboard(most_common_keypoint_id, 6, 'down', keyboard_TF=True, print_TF=False) presstime_2 = time.time() # print(time.time() - presstime_4 > 1) # 動態手勢控制 if most_common_fg_id[0][ 0] == 1 and most_common_fg_id[0][1] > 12: if time.time() - presstime_3 > 1.5: pyautogui.hotkey('shift', '>') print('speed up') presstime_3 = time.time() elif most_common_fg_id[0][ 0] == 2 and most_common_fg_id[0][1] > 12: if time.time() - presstime_3 > 1.5: pyautogui.hotkey('shift', '<') print('speed down') presstime_3 = time.time() # print(most_common_fg_id) # print(most_common_fg_id[0][0], most_common_fg_id[0][1]) # print(time.time() - presstime_3 > 1) if detect_mode == 2: if mouse_id == 0: # Point gesture # print(landmark_list[8]) #index finger # print(landmark_list[12]) #middle finger x1, y1 = landmark_list[8] # x2, y2 = landmark_list[12] # cv.rectangle(debug_image, (frameR, frameR), (cap_width - frameR, cap_height - frameR), # (255, 0, 255), 2) cv.rectangle(debug_image, (50, 50), (cap_width - 50, cap_height - 100), (255, 0, 255), 2) # x3 = np.interp(x1, (frameR, cap_width - frameR), (0, wScr)) # y3 = np.interp(y1, (frameR, cap_height - frameR), (0, hScr)) x3 = np.interp(x1, (50 * mousespeed, (cap_width - 50) / mousespeed), (0, wScr)) y3 = np.interp(y1, (50 * mousespeed, (cap_height - 50) / mousespeed), (0, hScr)) # print(x3, y3) # 6. Smoothen Values clocX = plocX + (x3 - plocX) / smoothening clocY = plocY + (y3 - plocY) / smoothening # 7. Move Mouse pyautogui.moveTo(clocX, clocY) cv.circle(debug_image, (x1, y1), 15, (255, 0, 255), cv.FILLED) plocX, plocY = clocX, clocY if mouse_id == 1: length, img, lineInfo = findDistance( landmark_list[8], landmark_list[12], debug_image) # 10. Click mouse if distance short if time.time() - clicktime > 0.5: if length < 40: cv.circle(img, (lineInfo[4], lineInfo[5]), 15, (0, 255, 0), cv.FILLED) pyautogui.click() print('click') clicktime = time.time() # if length > 70: # cv.circle(img, (lineInfo[4], lineInfo[5]), # 15, (0, 255, 0), cv.FILLED) # pyautogui.click(clicks=2) # print('click*2') # clicktime = time.time() if most_common_keypoint_id[0][ 0] == 5 and most_common_keypoint_id[0][1] == 5: pyautogui.scroll(20) if most_common_keypoint_id[0][ 0] == 6 and most_common_keypoint_id[0][1] == 5: pyautogui.scroll(-20) #if left_id == 7 or right_id == 7: if most_common_keypoint_id[0][ 0] == 0 and most_common_keypoint_id[0][1] == 5: if time.time() - clicktime > 1: pyautogui.click(clicks=2) clicktime = time.time() if most_common_keypoint_id[0][ 0] == 9 and most_common_keypoint_id[0][1] == 5: if time.time() - clicktime > 2: pyautogui.hotkey('alt', 'left') clicktime = time.time() cv.putText(debug_image, what_mode, (400, 30), cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 0), 4, cv.LINE_AA) # Screen reflection ###################################JL########################## cv.imshow('Hand Gesture Recognition', debug_image) cap.release() cv.destroyAllWindows()
if k <= ORDER_LIMIT: # start new order and collect wo# if order['sub_order'] in ('duplicate', 'changed'): # only for am to am fetchSubsequentOrder(order) orderCreation(order) # CREATE PATIENT CARD VIA SEARCH (MAIN) patientCardHandler(order) # IMPRESSION TYPE, FOOT TO SCAN (MAIN) footImpressionAndPONumberEntry(order, orders) # DEVICE SELECTION (MAIN) deviceSelection(order) # if error: # continue # Return to main screen pyautogui.hotkey('alt', 'g') time.sleep(2) pyautogui.typewrite(['right']) # Deleting impression if it was autofilled if order['sub_order'] in ('duplicate', 'changed'): pyautogui.typewrite(['delete']) # Move from foot impression type to shipment priority pyautogui.typewrite(['tab', 'tab', 'tab']) setOrderPriority(order) # Order Quanity 2 or more q_plus = order['quantity'] while q_plus - 1 > 0: q_plus = q_plus - 1
def Checkbutton(self): # ----------------------------------------------------- # [새글 피드 버튼을 찾는 함수 : Feed_Check] # ㄴ> 잡글 인식 및 무시 기능 포함 def Feed_check() : global moving_man moving_man = 0 while True : if moving_man == 1 : break else : while True : m.moveTo(954, 185) # 새글 피드 버튼 위치로 이동 for i in range(1, 3) : m.hotkey('Alt', 'Tab') # 'Alt+Tab'을 사용해 새글 피드 버튼 생성 확인 x, y = m.position() RGB = m.screenshot().getpixel((x, y)) # 색깔 잡기 if RGB == (46, 204, 113): # 새글 피드 버튼이 생기면 m.click(x, y) # 버튼 누르기 print('\n[system] : 새 글 확인 버튼을 눌렀습니다.') time.sleep(2) break else: time.sleep(10) # 없으면 10초 기다리기 m.moveTo(704, 400) # 출석체크 아이콘 버튼의 x좌표로 이동 time_limit = time.time() + (60) # 60초(1분) 안에 글에서 출석체크 아이콘을 못찾으면 잡글로 규정하고 패스 처리 while True : if time.time() > time_limit : print('\n[system] : 잡글을 인식했습니다. 피드 탐지를 재시작합니다.') break x, y = m.position() RGB = m.screenshot().getpixel((x, y)) # 색깔 잡기 if RGB == (52, 204, 108) or RGB == (255, 91, 114) or RGB == (255, 112, 61) or RGB == (147, 112, 240) or RGB == (50, 176, 229) or RGB == (248, 117, 192) or RGB == (33, 199, 0) or RGB == (253, 176, 13) or RGB == (0, 185, 148) or RGB == (84, 113, 216) : # 출석체크 아이콘 버튼의 색깔을 찾으면 # (순서대로) 회색&남색 / 주홍색 / 주황색 / 보라색 / 하늘색 / 분홍색 / 녹색 / 노란색 / 청록색 / 파란색 x, y = m.position() m.click(x, y) # 클릭해서 출석체크 창으로 이동 print('\n[system] : 출석체크 창으로 이동했습니다.') moving_man = 1 break else: # 그 색깔이 아니면 m.move(0, +1) # y축 방향으로 -1 만큼 이동 # ----------------------------------------------------- print('\nCheck button is clicked') print('\n[system] : 출석체크 자동 매크로를 시작합니다.') global moving_type moving_type = 0 while True : # 출석체크의 무한 츠쿠요미 time.sleep(2) m.click(1569, 122) # 새글 피드 화면만 보이도록 하기 # ----------------------------------------------------- if moving_type == 0 : # 새글 피드 버튼 체크를 위한 준비 (처음 실행했을 때 매크로창을 세 번째 창으로 만든다.) for i in range(1, 3): # (매크로창이 맨 앞에 올라와 있으면 Alt+Tab 정상적으로 동작 X) m.keyDown('Alt') for j in range(1, 3): m.press('Tab') m.keyUp('Alt') else : # 출석체크를 한 번 끝낸 후 for i in range(1, 3) : m.hotkey('Alt', 'Tab') # ----------------------------------------------------- Feed_check() # ----------------------------------------------------- time.sleep(2) m.moveTo(1149, 350) # 출석체크 체크 버튼의 x좌표로 이동 while True : x, y = m.position() RGB = m.screenshot().getpixel((x, y)) # 색깔 잡기 if RGB == (205, 205, 205) : x, y = m.position() m.click(x, y) # 클릭해서 출석체크 print('\n[system] : 출석체크를 완료했습니다.') moving_type = 1 break else: # 그 색깔이 아니면 m.move(0, +1) # y축 방향으로 -1 만큼 이동
def convert_hwp2docx(path): __path = path # 파일 세팅 ctypes.windll.Shell32.ShellExecuteW(None, 'open', __path, None, None, 1) print(1, datetime.now()) time.sleep(5) # 다른 이름으로 파일 저장하기 전 단계 pyautogui.hotkey('alt', 'f') print(2, datetime.now()) # 다른 이름으로 파일 저장하기 pyautogui.hotkey('alt', 'v') print(3, datetime.now()) # 파일 형식 지정하기 pyautogui.hotkey('alt', 't') print(4, datetime.now()) # 파일 형식 지정하기2 for i in range(20): pyautogui.hotkey('up') pyautogui.hotkey('down') pyautogui.hotkey('down') pyautogui.hotkey('down') pyautogui.hotkey('enter') print(5, datetime.now()) # 파일 저장하기 pyautogui.hotkey('alt', 'd') print(6, datetime.now()) # 파일 저장 확인 pyautogui.hotkey('c') # 열었던 프로그램 종료 pyautogui.hotkey('alt', 'f4') time.sleep(3) print("Convert Succeeded")
pyautogui.click(634, 605) time.sleep(5) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) #SENDCONFIG pyautogui.click(587, 564) time.sleep(1) pyautogui.typewrite('vivo') #pyautogui.typewrite('claro') pyautogui.hotkey('down') time.sleep(1) pyautogui.hotkey('enter') time.sleep(22) #LER ID pyautogui.click(545, 723) time.sleep(5) #LER SETUP pyautogui.click(640, 721) time.sleep(4) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) pyautogui.vscroll(-50) #SECURITY pyautogui.click(694, 603)
#!/usr/bin/env python3 import pyautogui as pag pag.hotkey('ctrl', 'shift', 'command', 'alt', 'z', interval=0.0)
def cexcel_from_html_above_v1(self, cliente, html_codigo): # # DEPOIS JUNTAR ELA COM GINFESS_SCRAP import os import pyautogui as pygui from pyperclip import paste, copy from time import sleep from .retornot import RetidosNorRetidos, RnrSo1 from .ginfess_scrap import cria_site_v1 """ :param cliente: nome do cliente vindo do loop :param competencia: vindo do GINFESS_download na linha 37 :param site_cria: (lugar_salvar) :return: return_full_path for with_titlePATH.txt """ client_path = self.client_path # impossível ser None driver = self.driver qtd_nf = driver.find_element_by_class_name('x-paging-info') qtd_text = qtd_nf.text proc = qtd_text.index('of') pal = qtd_text[proc:].split() qtd_text = pal[1] prossigo = cria_site_v1(html_codigo, qtd_text) _prossigo = prossigo[0] len_tables = prossigo[1] # input(f'{prossigo}, {len_tables}, {_prossigo}') sleep(5) if _prossigo: arq = f'rnc-{cliente}.xlsx' if len(arq) > 32: arq = f'rnc-{cliente.split()[0]}.xlsx' x, y = pygui.position() arq = f'{client_path}/{arq}' if '/' in client_path else f'{client_path}\\{arq}' # not really necessary, but i want to try: wb = Workbook() sh_name = client_path.split( '/')[-1] if '\\' not in client_path else client_path.split( '\\')[-1] sh_name = sh_name[:10] # limitando wb.create_sheet(sh_name) wb.active = 1 wb.remove(wb['Sheet']) wb.save(arq) except FileExistsError: pass finally: # ########## ABRINDO EXCEL ####### # program = arq.split('_')[-1] """~~~~""" os.startfile(arq) """~~~~""" sleep(12) allin = pygui.getAllWindows() for e, l in enumerate(allin): if program in l.title.lower(): l.restore() l.activate() l.maximize() # ########## ABRINDO ######### sleep(6) if len_tables > 1: RetidosNorRetidos() # input('RETIDOS N RETIDOS') pygui.hotkey('alt', 'f4') sleep(5) pygui.hotkey('enter') # from RETIDOS_N_RETIDOS import save_after_changes else: RnrSo1() print(f'Testado, len tables = {len_tables}')
def deviceSelection(order): pyautogui.hotkey('alt', 'm') time.sleep(1.5) if order['sameday_suborder'] == 'yes': pyautogui.typewrite(orders[order['suborder_target']]['wo_num']) pyautogui.typewrite(['down']) pyautogui.typewrite('changed device') pyautogui.hotkey('alt', 'm') pyautogui.typewrite(['tab', 'esc', 'tab', 'esc'], interval=SHORT_DELAY) pyautogui.typewrite(order['device_code']) pyautogui.typewrite(['return', 'return'], interval=SHORT_DELAY) while pyautogui.locateOnScreen(remove_button, region=(0, 0, 0, 0)) is None: time.sleep(1) else: if order['sub_order'] == 'new order': pyautogui.typewrite(['tab', 'esc', 'tab', 'esc'], interval=SHORT_DELAY) pyautogui.typewrite(order['device_code']) pyautogui.typewrite(['return', 'return'], interval=SHORT_DELAY) while pyautogui.locateOnScreen(remove_button, region=(0, 0, 0, 0)) is None: time.sleep(1) if order['sub_order'] == 'changed': if order['data_base'] == 'LFE': pyautogui.typewrite(['down']) pyautogui.typewrite('changed device') pyautogui.hotkey('alt', 'm') pyautogui.typewrite(['tab', 'esc', 'tab', 'esc'], interval=SHORT_DELAY) if order['device_code'] == '': order['device_code'] = '43170ST01' pyautogui.typewrite(order['device_code']) pyautogui.typewrite(['return', 'return'], interval=SHORT_DELAY) while pyautogui.locateOnScreen(remove_button, region=(0, 0, 0, 0)) is None: time.sleep(1) if order['data_base'] == 'AM': pyautogui.typewrite(['down', 'down']) pyautogui.typewrite(['prev_wo']) pyautogui.typewrite(['down', 'down', 'space']) if order['alter_subdevice'] == 'yes': pyautogui.typewrite(['space', 'tab', 'tab', 'tab']) if order['device_code'] == '': pyautogui.typewrite(order['prev_device']) else: pyautogui.typewrite(order['device_code']) if order['alter_subdevice'] == 'no': pyautogui.typewrite(['return', 'return', 'return']) pyautogui.typewrite(['return', 'return']) while pyautogui.locateOnScreen(remove_button, region=(0, 0, 0, 0)) is None: time.sleep(1) # TODO: Review code here for correctness, add quanity exception and normal dupe functionality # TODO: AM LFE differenciation if order['sub_order'] == 'duplicate': if order['data_base'] == 'LFE': pyautogui.typewrite(['down']) pyautogui.typewrite('duplicate') pyautogui.hotkey('alt', 'm') pyautogui.typewrite(['tab', 'esc', 'tab', 'esc'], interval=SHORT_DELAY) if order['device_code'] == '': order['device_code'] = '43170ST01' pyautogui.typewrite(order['device_code']) pyautogui.typewrite(['return', 'return'], interval=SHORT_DELAY) time.sleep(DEVICE_SELECTION_DELAY) if order['data_base'] == 'AM': pyautogui.typewrite(['down', 'down']) pyautogui.typewrite(['prev_wo']) pyautogui.typewrite(['down', 'space']) # for now will act like all dupe orders are dupes pyautogui.typewrite( ['tab', 'tab', 'tab', 'tab', 'tab', 'return']) #TODO - need to make code to determin when a dupe order is actually a changed order #TODO - code will be left here as naive until more developement done # if order['device_code'] == '': # pyautogui.typewrite(['tab', 'tab', 'tab', 'tab','tab','return']) # if order['alter_subdevice'] == 'yes': # pyautogui.typewrite(['space', 'tab', 'tab', 'tab', 'tab']) # if order['device_code'] == '': # pyautogui.typewrite(order['prev_device']) # else: # pyautogui.typewrite(order['device_code']) # if order['alter_subdevice'] == 'no': # pyautogui.typewrite(['return', 'return', 'return']) # # pyautogui.typewrite(['return', 'return']) time.sleep(DEVICE_SELECTION_DELAY)
def tc08(): #size = pyautogui.size() #pyautogui.click(1217, 12, duration=2) #pyautogui.typewrite("LINE") #pyautogui.typewrite(["enter"]) print("TestCase08 Start") for i in range(0, 30): # LineBot confirm #pyautogui.click(126, 48, duration=2) # LineSearch #pyautogui.typewrite("Yabo Thai") # GroupName #pyautogui.click(238, 146, duration=2) #pyperclip.copy("余额") #pyautogui.hotkey('command', 'v') #pyautogui.typewrite(["enter"]) #time.sleep(3) #balance = pyautogui.screenshot() #balance.save('GameStart_balance.png') #time.sleep(3) #pyautogui.click(398, 55, duration=1) # ClickClear # into Group1 test pyautogui.click(139, 86, duration=2) # LineSearch pyautogui.typewrite("SexyLineStgG1") # GroupName pyautogui.click(238, 146, duration=1) # Bet game pyautogui.typewrite("B100") pyautogui.typewrite(["enter"]) time.sleep(2) pyautogui.typewrite("T9") pyautogui.typewrite(["enter"]) time.sleep(2) pyautogui.typewrite("PP20001") pyautogui.typewrite(["enter"]) time.sleep(2) pyautogui.typewrite("pp100") pyautogui.typewrite(["enter"]) time.sleep(2) pyperclip.copy("ไพ่คู่เพลเยอร์ 100") #PP pyautogui.hotkey('command', 'v') pyautogui.typewrite(["enter"]) time.sleep(2) pyautogui.click(338, 85, duration=1) # ClickClear # into Group2 test pyautogui.click(139, 86, duration=2) # LineSearch pyautogui.typewrite("SexyLineStgG2") # GroupName pyautogui.click(238, 146, duration=1) # Bet game pyautogui.typewrite("P100") pyautogui.typewrite(["enter"]) time.sleep(2) pyautogui.typewrite("t100") pyautogui.typewrite(["enter"]) time.sleep(2) pyautogui.typewrite("BP100") pyautogui.typewrite(["enter"]) time.sleep(2) # LineBot Confirm pyautogui.click(338, 85, duration=1) # ClickClear pyautogui.click(139, 86, duration=2) # LineSearch pyautogui.typewrite("Yabo Thai") # GroupName pyautogui.click(238, 146, duration=2) pyperclip.copy("余额") pyautogui.hotkey('command', 'v') pyautogui.typewrite(["enter"]) time.sleep(3) balance = pyautogui.screenshot() balance.save('balance.png') time.sleep(3) pyautogui.click(338, 85, duration=1) # ClickClear print("Round", i + 1, "-- Done") print("TestCase08 Run Done")
def open_close_rv6699_panel(url): run_default_browser(url) time.sleep(2) pg.hotkey("ctrl", "c") os.system("python3 run-browser.py")
HS_Capturing = 0 # Leave holding station pyautogui.keyDown('enter') pyautogui.keyUp ('enter') break # Start with a side to increase waiting time pyautogui.keyDown('tab') time.sleep(PauseTime) pyautogui.keyDown('6') time.sleep(PauseTime) pyautogui.keyUp('tab') time.sleep(PauseTime) pyautogui.keyUp('6') pyautogui.hotkey('space') pyautogui.hotkey('space') pyautogui.keyDown('a') pyautogui.keyUp('a') FoodMaker(WindowGame,WindowsFoodRecipe) # A NEW DAWN OF FEASTING IS AT HAND start_time = time.time() while 'Screen capturing': # Get raw pixels from the screen, save it to a numpy array ImgGameWindow = cv2.cvtColor(np.array(sct.grab(WindowGame)), cv2.COLOR_RGBA2RGB) # For each holding station (but not at rush hour) elapsed_time = time.time() - start_time if elapsed_time < 90 or int(elapsed_time) in range(160,250) or elapsed_time > 310: for loopHSMake in range(0,len(WindowsHS['left'])):
def ctl_cv(info): pyperclip.copy(info) pag.hotkey('ctrl', 'v') print(f"填好信息:{info}")
for w in config.ofof: #если выключить if w in recog: writecontr = False talk("Деактивация режима печати") break break else: pass #основная проверка в режиме голосового управления if voicecontr == True: for w in config.window: # "окно" if w in recog: for w in config.left: # "лево" if w in recog: pyautogui.hotkey('win', 'left') time.sleep(1) pyautogui.press('esc') print('Окно слева') break for w in config.right: # "право" if w in recog: pyautogui.hotkey('win', 'right') time.sleep(1) pyautogui.press('esc') print('Окно справа') break for w in config.ofof: # "закрыть" if w in recog: pyautogui.hotkey('alt', 'f4') print('Закрыла окно')
def key(var1, var2='', var3='', var4=''): pyautogui.hotkey(var1, var2, var3, var4)