def test_animator_to_casaimageloader(cartavisInstance, cleanSlate): """ Test that we can change an animator to a CasaImageLoader """ # Get the animation window count and make sure it is non-zero animWindowList = len(cartavisInstance.getAnimatorViews()) assert animWindowList > 0 # Get the image window count imageWindowList = len(cartavisInstance.getImageViews()) # Locate an animator window and bring up the right-context menu, # changing to a CasaImageLoader. animatorWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png') pyautogui.doubleClick( x=animatorWindow[0], y=animatorWindow[1]) time.sleep(2) pyautogui.rightClick( x=animatorWindow[0], y=animatorWindow[1]) pyautogui.press('right') pyautogui.press('right') pyautogui.press('return') time.sleep(2) # Verify that the animation count has gone down by one and the image count # has increased by one newAnimWindowCount = len(cartavisInstance.getAnimatorViews()) newImageWindowCount = len(cartavisInstance.getImageViews()) assert newAnimWindowCount == animWindowList - 1 assert newImageWindowCount == imageWindowList + 1
def startMainQuests(): # click on Play logging.info("Looking for Play button...") while not getGameStatus(PLAY_PAGE): pyautogui.click(PLAY_BUTTON_COORDS, duration=0.25) time.sleep(2) logging.info("Clicked on Play button.") pyautogui.click(CHAPTER_ONE_BUTTON_COORDS, duration=0.25) logging.info("Clicked on Chapter 1 - Interdimensional Girls.") while not getGameStatus(INTERDIMENSIONAL_GIRLS_PAGE): time.sleep(2) pyautogui.click(SLOT_2_BUTTON_COORDS, duration=0.25) logging.info("Clicked on Quest 1 - Spice Run.") time.sleep(1) pyautogui.click(ACCEPT_QUEST_BUTTON_COORDS, duration=0.25) logging.info("Clicked on Accept Quest 1 - Spice Run.") time.sleep(2) pyautogui.click(PARTY_BEGIN_STORY_COORDS, duration=0.25) logging.info("Clicked on Party Accept Quest 1 - Spice Run.") time.sleep(2) # check if enough food if getGameStatus(FOOD_NOT_ENOUGH): pyautogui.click(CLOSE_NO_FOOD_BUTTON_COORDS, duration=0.25) logging.info("No food. Delay for 30 mins.") time.sleep(30 * 60) # wait for 30 mins logging.info("Wakes up.") pyautogui.click(PARTY_BEGIN_STORY_COORDS, duration=0.25) time.sleep(5) while not getGameStatus(QUEST_ONGOING_PAGE): time.sleep(2) logging.info("Quest not starting yet.") pyautogui.click(FAST_FORWARD_BUTTON_COORDS) logging.info("Clicked on Fast Forward button.") # no way to check if it's actually clicked time.sleep(2 * 60) # wait 3 mins quest_running = True while quest_running: # random mouse move to prevent screen saver # pyautogui.moveTo(random.randint(1, 10), random.randint(1, 10), 2) pyautogui.doubleClick(FAST_FORWARD_BUTTON_COORDS) time.sleep(10) quest_running = getGameStatus(QUEST_ONGOING_PAGE) if not quest_running: time.sleep(3) quest_running = getGameStatus(QUEST_ONGOING_PAGE) # check again to confirm while not getGameStatus(CEO_OFFICE_PAGE): pyautogui.click(CENTER_COORDS, duration=0.25) # continue clicking until back to CEO Office logging.info("Clicked to continue.") time.sleep(2)
def test_maximize_restore(cartavisInstance, cleanSlate): """ Test that a window can be maximized and then restored to its original position """ # Find and select the animation window animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png') assert animWindow != None pyautogui.doubleClick( x=animWindow[0], y=animWindow[1]) time.sleep(2) # Click the window button windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png') assert windowButton != None pyautogui.click( x=windowButton[0], y=windowButton[1]) # Look for the maximize button in the submenu pyautogui.press('down') pyautogui.press('return') time.sleep(2) # Verify that there is a single animator window assert len(cartavisInstance.getAnimatorViews()) == 1 # Right click the context menu to restore a animator window pyautogui.rightClick( x=animWindow[0], y=animWindow[1]) pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('right') pyautogui.press('return') time.sleep(2) # Verify that there are exactly the same number of windows as there were originally and the animation window is present assert len(cartavisInstance.getAnimatorViews()) == 1
def test_remove(cartavisInstance, cleanSlate): """ Test that an existing window can be removed """ windowCount = len(cartavisInstance.getPluginList()) # Find and select the animation window animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png') assert animWindow != None pyautogui.doubleClick( x=animWindow[0], y=animWindow[1]) time.sleep(2) pyautogui.rightClick( x=animWindow[0], y=animWindow[1]) time.sleep(2) # Look for the window button in the submenu and remove the window pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('right') pyautogui.press('down') pyautogui.press('down') pyautogui.press('return') time.sleep(2) # Verify that there is one animator window and no other windows assert len(cartavisInstance.getAnimatorViews()) == 1 assert len(cartavisInstance.getPluginList()) == 1 # Verify that there is one less window than there was originally and the animator window is not in the list assert len(cartavisInstance.getAnimatorViews()) == 0 assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
def moveAndDoubleClick (**options): displayMagnification = 2 if sysvar_ratina == True else 1 pyautogui.moveTo((options.get('top')/displayMagnification) + (options.get('width')/(displayMagnification*2)), (options.get('left')/displayMagnification) + (options.get('height')/(displayMagnification*2)), 2) pyautogui.doubleClick() pyautogui.moveTo(10, 10) # 10, 10 for avoid fail-safe
def up_a_level(self): """Presses ALT UP UP for a super vertical jump""" time.sleep(0.5) pyautogui.click(self.ALT) pyautogui.doubleClick(self.UP) pyautogui.mouseDown(self.UP) time.sleep(2.5) pyautogui.mouseUp()
def double_click(self, button='left', interval=0.0): '''Double clicks with the specified mouse button. See documentation of ``button`` in `Click`. ``interval`` specifies the time between clicks and should be floating point number. ''' ag.doubleClick(button=button, interval=float(interval))
def handle_command(command): lst = command.split(" ") if lst[0] == 'move': x = int(lst[1]) y = int(lst[2]) (mousex, mousey) = pyautogui.position() pyautogui.moveTo(mousex + x, mousey + y) else: if lst[0] == 'click': pyautogui.doubleClick()
def leftClickTwice(image): try: if type(image) == tuple: location = image else: location = pyautogui.locateOnScreen(image, grayscale=True) x, y = pyautogui.center(location) pyautogui.doubleClick(x, y) except TypeError: print 'double click error' + ' ' + image return leftClickTwice(image)
def click_image(image_file): x=0 y=0 x,y = find_image(image_file) if x and y: pyautogui.doubleClick(x,y) time.sleep(2) else: S = "Can not found %s !" % image_file print S S =S + "software will exit." pyautogui.alert(S, 'Alert') sys.exit()
def login(): pyautogui.moveTo(500,320) pyautogui.click(500,320) #time.sleep(0.5) pyautogui.doubleClick(450.320) pyautogui.typewrite(['backspace']) time.sleep(1) pyautogui.typewrite("sajjad_a_2", interval=0.1) time.sleep(0.75) pyautogui.click(500,370) pyautogui.typewrite("@S5233585a",interval=0.1) pyautogui.click(500,420) time.sleep(0.5)
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 test_animator_jump(cartavisInstance, cleanSlate): """ Set the channel animator to jump end behaviour. Save a preference snapshot. Set the channel animator to wrap end behaviour. Restore the preference snapshot. Check that the animator reverts back to jump behaviour. """ i = cartavisInstance.getImageViews() a = cartavisInstance.getAnimatorViews() # Set the animator to jump settingsButton = ImageUtil.locateCenterOnScreen( "test_images/animatorSettingsCheckBox.png") assert settingsButton != None pyautogui.click( x=settingsButton[0], y=settingsButton[1]) # Click the jump radio button jumpButton = ImageUtil.locateCenterOnScreen('test_images/jumpButton.png') assert jumpButton != None pyautogui.doubleClick( x=jumpButton[0], y=jumpButton[1]) # Save a snapshot. Make sure preferences are checked and layout and data are not checked s = cartavisInstance.newSnapshot('some_session_id','tSnapshotPreferences', False, True, False, '') s.save() # Find the wrap radio button in the animator settings and click it wrapButton = ImageUtil.locateCenterOnScreen('test_images/wrapButton.png') assert wrapButton != None pyautogui.click( x=wrapButton[0], y=wrapButton[1]) # Restore the preferences s[0].restore() time.sleep(2) # Verify the animator jump end behaviour is checked by checking end behaviour a[0].setChannel(0) lastChannel = i[0].getChannelCount() - 1 # Go to the next channel incrementButton = ImageUtil.locateCenterOnScreen( "test_images/incrementButton.png") assert incrementButton != None pyautogui.click( x=incrementButton[0], y=incrementButton[1]) time.sleep(2) assert a[0].getChannelIndex() == lastChannel s[0].delete()
def test_global_prefs(cartavisInstance, cleanSlate): """ Test that object specific settings can also act globally. Set the animator to jump. Save the preferences. Open two animators. Restore the preferences. Check the second animator is also set to jump. """ # Set the animator to jump settingsButton = ImageUtil.locateCenterOnScreen( "test_images/animatorSettingsCheckBox.png") assert settingsButton != None pyautogui.click( x=settingsButton[0], y=settingsButton[1]) # Click the jump radio button jumpButton = ImageUtil.locateCenterOnScreen('test_images/jumpButton.png') assert jumpButton != None pyautogui.doubleClick( x=jumpButton[0], y=jumpButton[1]) # Save a snapshot. Make sure preferences are checked and # layout and data are not checked s = cartavisInstance.newSnapshot('some_session_id','tSnapshotPreferences', False, True, False, '') s.save() # Find an image window and change it into an animator imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png') assert imageWindow != None pyautogui.rightClick( x=imageWindow[0], y=imageWindow[1]) pyautogui.press('right') pyautogui.press('right') pyautogui.press('down') pyautogui.press('return') time.sleep(2) # Find the settings button on the animator and click it so the jump will be visible settingsButton = ImageUtil.locateCenterOnScreen('test_images/settingsCheckBox.png') assert settingsButton != None pyautogui.click( x=settingsButton[0], y=settingsButton[1]) # Restore the preferences s[0].restore() # Check that both animators are not displaying jump # Verify that the animator jump end behaviour is checked in the screenshot after the tests have been run pyautogui.screenshot('layout_check/bothAnimatorsJump.png') s[0].delete()
def follow(): #pyautogui.moveTo(500,320) #pyautogui.click(500,320) pyautogui.click(1275,730) time.sleep(1) pyautogui.click(225,110) time.sleep(1) pyautogui.click(1050,175) time.sleep(4) pyautogui.click(680,150) time.sleep(3) #wait = input("countinue? ") pyautogui.click(480,650) # open image time.sleep(0.5) pyautogui.click(580,250) pyautogui.doubleClick(580,250) pyautogui.click(410,50) # back time.sleep(0.2) pyautogui.click(410,50) #back time.sleep(0.5)
def copyVerCode(): pyautogui.click(1275,730) time.sleep(1) pyautogui.click(820,370) time.sleep(1) pyautogui.click(500,150) time.sleep(1) pyautogui.mouseDown(500, 150, button='left') time.sleep(1.5) pyautogui.mouseUp(500, 150, button='left') time.sleep(1) pyautogui.click(500,390) time.sleep(1) pyautogui.click(500,680) time.sleep(1) pyautogui.hotkey('ctrl', 'v') time.sleep(1) pyautogui.doubleClick(500,680) time.sleep(1) pyautogui.click(520,710) pyautogui.dragTo(540, 715, duration=0.5)
def test_maximize_removed(cartavisInstance, cleanSlate): """ Test that a window can be maximized and then removed. """ windowCount = len(cartavisInstance.getPluginList()) # Find and select the animation window animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png') assert animWindow != None pyautogui.click( x=animWindow[0], y=animWindow[1]) # Click the window button windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png') assert windowButton != None pyautogui.click( x=windowButton[0], y=windowButton[1]) time.sleep(2) # Look for the maximize button in the submenu pyautogui.press('down') pyautogui.press('return') time.sleep(2) # Verify there is a single animator window assert len(cartavisInstance.getAnimatorViews()) == 1 # Now right click the context menu to remove the animator window pyautogui.doubleClick( x=animWindow[0], y=animWindow[1]) time.sleep(2) pyautogui.rightClick( x=animWindow[0], y=animWindow[1]) pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('right') pyautogui.press('down') pyautogui.press('return') time.sleep(2) # Verify that there is one less window than there was originally and the animation window is not in the list assert len(cartavisInstance.getAnimatorViews()) == 0 assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
def new_image_window(): # Click on an existing image window imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png') assert imageWindow != None, 'Could not find an image window on the current display' pyautogui.click( x=imageWindow[0], y=imageWindow[1]) time.sleep(3) # Click on the window button windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png') assert windowButton != None, 'Could not find the window button on the menu bar' pyautogui.doubleClick( x=windowButton[0], y=windowButton[1]) time.sleep(2) # Locate the add button and click on it pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('right') pyautogui.press('return') time.sleep(2) # Change the plugin of the empty window to a casa image loader cartavisInstance.setEmptyWindowPlugin(0, 'CasaImageLoader')
def pyclick(x,y): pyautogui.moveTo(x, y) pyautogui.doubleClick()
def dataReceived(self, data): #fetch commands from data cmds = data.split(';'); #exec each command for cmd in cmds: # cmd = object : action < :param < :param < :param ... >>> # each cmd contains atleast 'object' & 'action' splitted = cmd.split(':'); #invalid cmd? if (len(splitted)<2): continue #number of params params = len(splitted)-2 obj = splitted[0] act = splitted[1] if obj == "mouse": if act == "click": if params == 0: pyautogui.click() #click provided a parameter: number of clicks! elif params == 1: clicks = int(float(splitted[2])) pyautogui.click(clicks=clicks) elif act == "doubleclick": pyautogui.doubleClick() elif act == "tripleclick": pyautogui.tripleClick() elif act == "rightclick": pyautogui.rightClick() elif act == "scroll": if params == 2: x = int(float(splitted[2])) y = int(float(splitted[3])) pyautogui.hscroll(x); pyautogui.vscroll(y); elif act == "drag": if params == 1: # indicate that dragging is activated, but not yet started if splitted[2] == "start": self.dragActive = True # indicate that dragging in disactivated elif splitted[2] == "end": self.dragActive = False #stop dragging when active if self.dragStarted: self.dragStarted = False pyautogui.mouseUp() else: print "Unknown value for 'drag':" + splitted[2] elif params == 2: #are we already dragging? if not self.dragStarted: self.dragStarted = True pyautogui.mouseDown() #fetch x/y movement x = int(float(splitted[2])) y = int(float(splitted[3])) pyautogui.dragRel(x,y, mouseDownUp=False) elif act == "move": if params == 2: #fetch x/y movement x = int(float(splitted[2])) y = int(float(splitted[3])) #are we dragging? pyautogui.moveRel(x,y) elif obj == "key": key = splitted[2] print("keypress:" + act + " key:" + key) if (act == "press"): pyautogui.press(key) elif (act == "down"): pyautogui.keyDown(key) elif (act == "up"): pyautogui.keyUp(key)
def click_image_double(image, pos, action, timestamp, offset=5): img = cv2.imread(image) height, width, channels = img.shape pyautogui.moveTo(pos[0] + r(width / 2, offset), pos[1] + r(height / 2, offset), timestamp) pyautogui.doubleClick(button=action)
import pyautogui print(pyautogui.position()) i = 0 while i < 2: pyautogui.moveRel(0, 50, 1) a = pyautogui.position() pyautogui.doubleClick() pyautogui.moveTo(901, 44, 0.1) pyautogui.click() pyautogui.moveTo(698, 87, 0.5) pyautogui.click() pyautogui.moveTo(73, 242, 3) pyautogui.click() pyautogui.moveTo(a[0], a[1], 1) i = i + 1 #pyautogui.scroll(-800)
If key presses worked for EIPC this would open export menu pyautogui.keyDown('alt') pyautogui.press('o') pyautogui.keyUp('alt') ''' # Opens export tab and clicks export to file pyautogui.PAUSE = 2 pyautogui.click(205, 108) pyautogui.click(280, 226) # Pause to let big reports load here. pyautogui.PAUSE = 300 # Click load all dialogue box to load big reports pyautogui.click(1023, 571) pyautogui.PAUSE = 3 # types file name and saves to INBOX pyautogui.doubleClick(282, 384) pyautogui.press('del') # Rename report in Phrase Express pyautogui.typewrite('xxbhct') # switched to AutoHotkey, no longer need backspace. Space triggers snippet. pyautogui.press('space') # pyautogui.press('backspace') pyautogui.PAUSE = 30 pyautogui.click(515, 382) # closes EPIC pyautogui.click(1901, 8) pyautogui.click(1016, 563)
import re import datetime import pyautogui import time import PIL from Tkinter import Tk from PIL import Image smile = Image.open('smile.bmp') brandon_folder = Image.open('brandon.bmp') brandon_target = Image.open('brandon_target.bmp') pyautogui.doubleClick(pyautogui.locateCenterOnScreen(brandon_folder)) print 'found' time.sleep(2) pyautogui.doubleClick(pyautogui.locateCenterOnScreen(brandon_target)) print 'fin' time.sleep(2) pyautogui.typewrite(['f11']) exit() center_list = list(pyautogui.center(pyautogui.locateOnScreen(smile))) print center_list center_list[0] = center_list[0] - 80 center = tuple(center_list) print center pyautogui.doubleClick(center)
def press_key(key_name, delay): rand_num = random.randint(-5, 5) key_pos = key_dict[key_name] pa.doubleClick(key_pos[0] + rand_num, key_pos[1] + rand_num) pa.PAUSE = delay
def ColvirAdmin_block(names, log_table): n = 2 for i in range(n): # open ColvirAdmin login_cbs_adm = "arnurt" password_cbs_adm = "arnur_010203" pythonRPA.application("C:\CBS_T_новый\CBSADM.exe").start() #Введение данных для входа log_in = pythonRPA.bySelector([{ "title": "Вход в систему", "class_name": "TfrmLoginDlg", "backend": "uia" }]) log_in.wait_appear(30) log_in.click() log_in.set_focus() pythonRPA.keyboard.write(login_cbs_adm) pythonRPA.keyboard.press("Enter") pythonRPA.keyboard.write(password_cbs_adm) pythonRPA.keyboard.press('Enter') cbs_adm_main_window = pythonRPA.bySelector([{ "class_name": "TfrmCssApplAdm", "backend": "uia" }]) cbs_adm_main_window.wait_appear(10) cbs_adm_main_window.set_focus() #Сохранение селекторов Колвир Админ filter = pythonRPA.bySelector([{ "title": "Фильтр", "class_name": "TfrmFilterParams", "backend": "uia" }]) filter_name_line = pythonRPA.bySelector([{ "title": "Фильтр", "class_name": "TfrmFilterParams", "backend": "uia" }, { "ctrl_index": 0 }, { "ctrl_index": 0 }, { "ctrl_index": 0 }]) filter_cbs_ok = pythonRPA.bySelector([{ "title": "Фильтр", "class_name": "TfrmFilterParams", "backend": "uia" }, { "ctrl_index": 1 }, { "ctrl_index": 0 }, { "ctrl_index": 2 }]) for name in names: # openning the filter by cliking the Пользователи try: blocked_codes = [] unblocked_codes = [] for iterr in range(50): try: x, y = pyautogui.locateCenterOnScreen( r'.\Utils\users.png') pyautogui.doubleClick(x, y) print('Пользователи pressed') break except Exception as e: print(e) pythonRPA.sleep(1) pythonRPA.sleep(2) filter.set_focus() # Clearing the FILTER for iterr in range(50): try: x, y = pyautogui.locateCenterOnScreen( r'.\Utils\clear_filter_button.png') pyautogui.doubleClick(x, y) print('clear_filter_button pressed') break except Exception as e: print(e) pythonRPA.sleep(1) filter_name_line.click() # fill name_line pythonRPA.keyboard.write(name) # clicking OK to search filter_cbs_ok.click() pythonRPA.sleep(3) code = "npos" #Проверка на результат warming = pythonRPA.bySelector([{ "title": "Подтверждение", "class_name": "TMessageForm", "backend": "uia" }]) warming.wait_appear(1) unfound = warming.is_exists() if unfound: if i: for row in log_table: if row[0] == name and row[1] == 'CBSADM': change_row(log_table, row, name, "CBSADM", "Не заблокирован", "Сотрудник не найден в системе", datetime.now().strftime("%H:%M:%S")) else: log_table.append([ name, "CBSADM", "Не заблокирован", "Сотрудник не найден в системе", datetime.now().strftime("%H:%M:%S") ]) print("Not found in system") pythonRPA.keyboard.press('enter') continue else: used = False while 1: # Getting the CODE of the user # i = 1 if (used): pythonRPA.keyboard.press('down') pythonRPA.keyboard.press('Enter') used = True user_detail_window = pythonRPA.bySelector([{ "class_name": "TfrmAdmUsrDetail", "backend": "uia" }]) user_detail_window.wait_appear(2) CODE_line = pythonRPA.bySelector([{ "class_name": "TfrmAdmUsrDetail", "backend": "uia" }, { "ctrl_index": 0 }, { "ctrl_index": 0 }, { "ctrl_index": 0 }, { "ctrl_index": 2 }, { "ctrl_index": 0 }]) # check do we blocked this account in past itteration?? if (CODE_line.get_value() == code): break code = CODE_line.get_value() # Флаг проеверки должна ли программа нажать кнопку архив, изначально думаем что должна archive_сlick = True # Флаг проеверки должна ли программа нажать кнопку блокировки, изначально думаем что должна block_click = True try: x, y = pyautogui.locateCenterOnScreen( r'.\Utils\archive.png') archive_сlick = False # Флаг проеверки становится ложной если он и так нажат except Exception as e: print(e) n += 1 print('archive ', archive_сlick) try: x, y = pyautogui.locateCenterOnScreen( r'.\Utils\blocked.png') block_click = False print('block_click ', block_click) # Флаг проеверки становится ложной если он и так нажат except Exception as e: print(e) print('block_click ', block_click) # Кнопка "Пользователь" user_button = pythonRPA.bySelector([{ "class_name": "TfrmAdmUsrDetail", "backend": "uia" }, { "ctrl_index": 4 }, { "ctrl_index": 0 }]) # В сулачае если галочки нету или же кнопка блокировки не нажата мы должны ввести изминения if (archive_сlick): # Нажимаем кнопку корректировки user_button.wait_appear(2) user_button.click() for i in range(3): pythonRPA.keyboard.press('down') pythonRPA.keyboard.press('Enter') # making enable the checkbox of the archive try: x, y = pyautogui.locateCenterOnScreen( r'.\Utils\arxiv.png') pyautogui.click(x + (x / 2), y) print('Архив нажат') except Exception as e: print(e) # Saving the changes user_button.wait_appear(2) user_button.click() for i in range(2): pythonRPA.keyboard.press('down') pythonRPA.keyboard.press('Enter') # Blocking the user if block_click: user_button.wait_appear(2) user_button.click() for i in range(9): pythonRPA.keyboard.press('down') for i in range(3): pythonRPA.sleep(0.5) pythonRPA.keyboard.press('Enter') user_detail_window.close() print(code, "sucsessfully blocked in CBS/ADM.exe") if not i: log_table.append([ name, "CBSADM", "Заблокирован", "", datetime.now().strftime("%H:%M:%S") ]) else: for row in log_table: if row[0] == name and row[1] == 'CBSADM': change_row(log_table, row, name, "CBSADM", "Заблокирован", "", datetime.now().strftime("%H:%M:%S")) except: if i: for row in log_table: if row[0] == name and row[1] == 'CBSADM': change_row(log_table, row, name, "CBSADM", "Не заблокирован", "Техническая ошибка", datetime.now().strftime("%H:%M:%S")) else: log_table.append([ name, "CBSADM", "Не заблокирован", "Техническая ошибка", datetime.now().strftime("%H:%M:%S") ])
from flask import Flask, render_template, jsonify, request import pyautogui app = Flask(__name__) from pymongo import MongoClient client = MongoClient('localhost', 27017) db = client.dbhomework #현대카드 홈페이지 pyautogui.moveTo(51,58,2) pyautogui.doubleClick(x=51,y=58, button='left') #현대카드 아이디 pyautogui.moveTo(233,485,3) pyautogui.click(x=233,y=485) #현대카드 횸페이지 내리기 pyautogui.moveTo(1779,19,3) pyautogui.click(x=1779,y=19) #아이디 화면 띄우기 pyautogui.moveTo(138,71,3) pyautogui.doubleClick(x=138,y=71, button='left') #아이디 글씨 클릭 후 드래그 pyautogui.moveTo(593,336,3) pyautogui.dragTo(682,332,1,button='left') #아이디 글씨 드래그 후 복사 pyautogui.moveTo(645,335,1) pyautogui.click(x=645,y=335,button='right') #아이디 글씨 드래그 후 복사 버튼 클릭 pyautogui.moveTo(675,352,1) pyautogui.click(x=675,y=352,button='left')
def ControlMouseAndKeyboardUsingCustomGestures(): # use global variables global current_attr global previous_attr winmac = 'ctrl' winmac2 = 'alt' if machine_value == 1: # if mac, change string to 'command' winmac = 'command' winmac2 = 'option' # [area1, x1, y1, MA1, ma1, angle1, hasArea1, area2, x2, y2, MA2, ma2, angle2, hasArea2, fingerCount1, cX1, cY1, hasFinger1, fingerCount2, cX2, cY2, hasFinger2] # use these attributes for simple and complex gestures # for angle, right hand (angle1) points up -> 30 degrees; left hand (angle2) points up -> 150 degrees if gesture_value == 0: # only apply simple gestures # example gesture to exhibit (on desktop and in words) # finger==0, one hand hull moving # angle>120 or angle<60, single right click # finger==2, double click # finger==4+4, press space (two hands) # two roi points up, select all (two hands) # one roi is significantly above another one, close window # part 2 info hasArea1 = current_attr[attribute_dict['hasArea1']] hasArea2 = current_attr[attribute_dict['hasArea2']] angle1 = current_attr[attribute_dict['angle1']] angle2 = current_attr[attribute_dict['angle2']] y1 = current_attr[attribute_dict['Y1']] y2 = current_attr[attribute_dict['Y2']] # part 3 info hasFinger1 = current_attr[attribute_dict['hasFinger1']] hasFinger2 = current_attr[attribute_dict['hasFinger2']] finger1 = current_attr[attribute_dict['fingerCount1']] finger2 = current_attr[attribute_dict['fingerCount2']] cX = current_attr[attribute_dict['cX1']] cY = current_attr[attribute_dict['cY1']] if image_value == 2: # gesture 2: angle>120 or angle<60, single right click (one hand) if hasArea1 > 1 and hasArea2 == 1 and (angle1 > 120 or angle1 < 60): # the ring on hand points either up or down pyautogui.rightClick() # gesture 5: two roi points up, select all (two hands) if hasArea1 > 1 and hasArea2 > 1 and angle1 < 60 and angle2 > 120: pyautogui.hotkey(winmac, 'a') # gesture 6: one roi is significantly above another one, close window if y1 > y2 + threshold_value or y2 > y1 + threshold_value: pyautogui.hotkey(winmac, 'w') if image_value == 3: # gesture 1: finger==0, one hand hull moving if hasFinger1 > 1 and hasFinger2 == 1 and finger1 == 0: # one hand position moving, if cX and cY are not out of bound mcX = offsetX + scaleX * cX mcY = offsetY + scaleY * cY if mcX > 0 and mcY > 0 and mcX < monwidth and mcY < monheight: pyautogui.moveTo(cX, cY, duration=0.02, tween=pyautogui.easeInOutQuad) # gesture 3: finger==2, double click if hasFinger1 > 1 and hasFinger2 == 1 and finger1 == 2: pyautogui.doubleClick() # gesture 4: finger==4+4, press space (two hands) if hasFinger1 > 1 and hasFinger2 > 1 and finger1 == 4 and finger2 == 4: pyautogui.press('space') # etc ... elif gesture_value == 1: # only apply complex gestures # example gestures to exhibit (in windows photo app) # one roi area decrease and angle does not change too much, save as (ctrl + s) # one roi angle changes, rotate (ctrl + r) # finger change from 2 to 4, add current photo to album (ctrl + d) # finger keeps 5 and hand move right (wave), back to collection (esc) # two roi distance changing, zoom in and out (ctrl + / ctrl -) # finger changes from 2+2 to 4+4, file info (alt + enter) # two roi area decrease, go into selection mode (space) # two hands wave together (2 fingers each), select this image (enter) # part 2 info hasArea1 = current_attr[attribute_dict['hasArea1']] hasArea2 = current_attr[attribute_dict['hasArea2']] area1 = current_attr[attribute_dict['area1']] area2 = current_attr[attribute_dict['area2']] angle1 = current_attr[attribute_dict['angle1']] angle2 = current_attr[attribute_dict['angle2']] x1 = current_attr[attribute_dict['X1']] y1 = current_attr[attribute_dict['Y1']] x2 = current_attr[attribute_dict['X2']] y2 = current_attr[attribute_dict['Y2']] phasArea1 = previous_attr[attribute_dict['hasArea1']] phasArea2 = previous_attr[attribute_dict['hasArea2']] parea1 = previous_attr[attribute_dict['area1']] parea2 = previous_attr[attribute_dict['area2']] pangle1 = previous_attr[attribute_dict['angle1']] pangle2 = previous_attr[attribute_dict['angle2']] px1 = previous_attr[attribute_dict['X1']] py1 = previous_attr[attribute_dict['Y1']] px2 = previous_attr[attribute_dict['X2']] py2 = previous_attr[attribute_dict['Y2']] # part 3 info hasFinger1 = current_attr[attribute_dict['hasFinger1']] hasFinger2 = current_attr[attribute_dict['hasFinger2']] finger1 = current_attr[attribute_dict['fingerCount1']] finger2 = current_attr[attribute_dict['fingerCount2']] cX1 = current_attr[attribute_dict['cX1']] cY1 = current_attr[attribute_dict['cY1']] cX2 = current_attr[attribute_dict['cX2']] cY2 = current_attr[attribute_dict['cY2']] phasFinger1 = previous_attr[attribute_dict['hasFinger1']] phasFinger2 = previous_attr[attribute_dict['hasFinger2']] pfinger1 = previous_attr[attribute_dict['fingerCount1']] pfinger2 = previous_attr[attribute_dict['fingerCount2']] pcX1 = previous_attr[attribute_dict['cX1']] pcY1 = previous_attr[attribute_dict['cY1']] pcX2 = previous_attr[attribute_dict['cX2']] pcY2 = previous_attr[attribute_dict['cY2']] if image_value == 2: # gesture 1: one roi area decrease and angle does not change too much, save as (ctrl + s) if hasArea1 > 1 and phasArea1 > 1 and hasArea2 == 1 and phasArea2 == 1 and area1 < parea1 - threshold_value * 10 and angle1 > pangle1 - threshold_value and angle1 < pangle1 + threshold_value: pyautogui.hotkey(winmac, 's') # gesture 2: one roi angle changes to larger than 120, rotate (ctrl + r) if hasArea1 > 1 and phasArea1 > 1 and hasArea2 == 1 and phasArea2 == 1 and ( angle1 < pangle1 - threshold_value or angle1 > pangle1 + threshold_value): pyautogui.hotkey(winmac, 'r') # gesture 5: two roi distance changing, zoom in and out (ctrl + / ctrl -) if hasArea1 > 1 and phasArea1 > 1 and hasArea2 > 1 and phasArea2 > 1: dist = np.sqrt((x1 - x2)**2 + (y1 - y2)**2) pdist = np.sqrt((px1 - px2)**2 + (py1 - py2)**2) if dist > pdist + threshold_value: pyautogui.hotkey(winmac, '+') elif dist < pdist - threshold_value: pyautogui.hotkey(winmac, '-') # gesture 7: two roi area decrease, go into selection mode (space) if hasArea1 > 1 and phasArea1 > 1 and hasArea2 > 1 and phasArea2 > 1 and area1 < parea1 - threshold_value and area2 < parea2 - threshold_value: pyautogui.press('space') elif image_value == 3: # gesture 3: finger change from 2 to 4,add current photo to album (ctrl + d) if hasFinger1 > 1 and phasFinger1 > 1 and hasFinger2 == 1 and phasFinger2 == 1 and finger1 == 4 and pfinger1 == 2: pyautogui.hotkey(winmac, 'd') # gesture 4: finger keeps 5 and hand move right (wave), back to collection (esc) if hasFinger1 > 1 and phasFinger1 > 1 and hasFinger2 == 1 and phasFinger2 == 1 and finger1 == 5 and pfinger1 == 5 and cX1 > pcX1 + threshold_value: pyautogui.press('esc') # gesture 6: finger changes from 4 to 8, file info (alt + enter) if hasFinger1 > 1 and phasFinger1 > 1 and hasFinger2 > 1 and phasFinger2 > 1 and finger1 == 4 and pfinger1 == 2 and finger2 == 4 and pfinger2 == 2: pyautogui.hotkey(winmac2, 'enter') # gesture 8: two hands wave together, select this image (enter) if hasFinger1 > 1 and phasFinger1 > 1 and hasFinger2 > 1 and phasFinger2 > 1 and finger1 == 2 and pfinger1 == 2 and finger2 == 2 and pfinger2 == 2: dist = abs(cX1 - cX2) pdist = abs(pcX1 - pcX2) if dist < pdist - threshold_value: pyautogui.press('enter') # etc ... # move current_attr to previous_attr previous_attr = current_attr
import time pyautogui.FAILSAFE = True #(False 값을 넣을 경우 오류 발생시 실행 멈추지 않음) pyautogui.position() f = open('c:\\Users\\S\\Desktop\\code_list.txt', 'r') lines = f.readlines() code_list = [] for line in lines: nline = line.split('\n')[0] code_list.append(nline) # code_list = missingcode # for test i = 1 for code_name in code_list: print(i,"/", len(code_list)) i += 1 pyautogui.click(x=113, y=181) time.sleep(0.2) pyautogui.click(x=254, y=302) pyautogui.typewrite(code_name) time.sleep(0.5) pyautogui.doubleClick(x=190, y=351) time.sleep(0.5) pyautogui.click(x=368, y=354, button='right') time.sleep(0.2) pyautogui.click(x=411, y=601) time.sleep(0.2) pyautogui.typewrite(code_name) time.sleep(0.5) pyautogui.click(x=757, y=594) time.sleep(0.5)
def doubleClkImg(self, imgpath: str): try: pyautogui.doubleClick(imgpath) print("Image has been clicked") except Exception as e: print(e + " Error occur to click the image")
def search_pid(pid_number): sc.get_m1_coordinates() pyautogui.doubleClick(m1['search']) keyboard.write(pid_number) pyautogui.click(m1['find_now']) pyautogui.click(m1['change'])
import pyautogui as pag import time as t import sys pag.PAUSE = 0.5 pag.FAILSAFE = True puttyX = 5 puttyY = 125 RPiX = 697 RPiY = 527 openX = 834 openY = 688 pag.moveTo(puttyX, puttyY) pag.doubleClick() pag.moveTo(RPiX, RPiY) pag.click() pag.moveTo(openX, openY) pag.click() t.sleep(3) pag.typewrite("pi", pause=True) pag.press("enter") t.sleep(.5) pag.typewrite("raspberry", pause=True) pag.press("enter") t.sleep(2) pag.typewrite("sudo python3 relay1.py") pag.press("enter")
if status[i] == "Done" or status[i] == "Skip": print(productPartNo + " is Done") continue if status[i] == "Stop": print("Stop here") break print("code is" + productPartNo) storeTemplateWindow.child_window(title="Code", control_type="ComboBox").click_input() # click on the Code Edit Box pyautogui.typewrite(productPartNo) pyautogui.moveRel(0, 25) pyautogui.PAUSE = 0.5 pyautogui.doubleClick() # open the site by double click print("current row is: " + str(i)) # productsSelectWindow.Close.click_input() # pyautogui.PAUSE = 2.5 # storeTemplateWindow.Save.click_input() # pyautogui.PAUSE = 2.5 # print (str(templateName[i]) + " is Done now") # print ("#########################") # print (" ") print("----Done----")
import pyautogui print(pyautogui.size()) width, height = pyautogui.size() print(pyautogui.position()) pyautogui.moveTo(10,10) pyautogui.moveTo(10,10,duration=1.5) pyautogui.moveRel(200,0,duration=2) print(pyautogui.position()) pyautogui.click(339,38) pyautogui.doubleClick(339,38) pyautogui.rightClick(339,38)
# auto.moveTo(i,i*2) auto.moveTo(1230, 30, duration=0.5) auto.scroll(-200) auto.click() # auto.dragRel(20,30) # auto.dragRel(20,-30) a = 300 # auto.KEYBOARD_KEYS # auto.typewrite() me shkru # auto.hotkey() mi prek disa tastet per menjehere auto.moveTo(20, 360) auto.click() # auto.locateOnScreen() e merr ni foto si argument e tkallxon ku osht ne screen auto.moveTo(323, 306, duration=0.5) auto.dragTo(655, 610, duration=0.5) auto.doubleClick() auto.moveTo(20, 215, duration=0.5) auto.moveTo(30, 475) auto.click() auto.moveTo(200, 510) auto.click() auto.moveTo(350, 320, duration=0.5) while a > 0: auto.dragRel(a, 0) a -= 20 auto.dragRel(0, a) a -= 20 auto.dragRel(-a, 0) a -= 20 auto.dragRel(0, -a) a -= 20
def click4(): global freeevening global date3 global date4 global date2 global date hours = random.randint(10, 11) minuts = random.randint(10, 59) date = f"{hours}:{minuts}" hourst = random.randint(0, 2) minutst = random.randint(10, 59) date2 = f"0{hourst}:{minutst}" rsiesta = random.randint(0, 5) if rsiesta == 0: freeevening = True print(datetime.datetime.now()) print("Will take a break next evening") else: print(datetime.datetime.now()) print("Click after launch") launchdelay = random.randint(1, 60) time.sleep(launchdelay) pyautogui.doubleClick(500, 100) #randomstops breaksevening = random.randint(0, 3) if breaksevening != 0: rsleep = random.randint(300, 2500) rback = random.randint(360, 5000) print(datetime.datetime.now()) print( f"Will take a break of {rback} seconds after {rsleep} seconds") time.sleep(rsleep) pyautogui.doubleClick(500, 100) time.sleep(rback) pyautogui.doubleClick(500, 100) print(datetime.datetime.now()) print("End of the break") if breaksevening != 1: rsleep2 = random.randint(300, 3000) rback2 = random.randint(360, 9900) print(datetime.datetime.now()) print( f"Will take a break of {rback2} seconds after {rsleep2} seconds" ) time.sleep(rsleep2) pyautogui.doubleClick(500, 100) time.sleep(rback2) pyautogui.doubleClick(500, 100) print(datetime.datetime.now()) print("End of the break") if breaksevening != 2: rsleep3 = random.randint(400, 1500) rback3 = random.randint(360, 8500) print(datetime.datetime.now()) print( f"Will take a break of {rback3} seconds after {rsleep3} seconds" ) time.sleep(rsleep3) pyautogui.doubleClick(500, 100) time.sleep(rback3) pyautogui.doubleClick(500, 100) print(datetime.datetime.now()) print("End of the break")
import pyautogui as p from time import sleep # Identified position of Google Chrome in Desktop # sleep(2) # print(p.position()) p.doubleClick(x=121, y=121) sleep(4) p.write('https://www.udemy.com/ ') sleep(1) window = p.getActiveWindow() window.maximize() sleep(3) p.press('enter') sleep(4) window = p.getActiveWindow() window.maximize() sleep(5) localSearch = p.locateOnScreen('Pesquisa.png', confidence=0.9) # print(localSearch) # valor das medidas pode mudar de acordo com a resolução do # monitor utilizado. locateSearch = p.center(localSearch) print(locateSearch) p.click(locateSearch) sleep(2) p.write('RPA') p.press('enter') sleep(2)
def navicat_auto(): start_time = time.time() st = dt.datetime.fromtimestamp(start_time).strftime('%Y-%m-%d %H:%M:%S') st, a = st.split(" ") path = r"C:\Users\vriosto\Desktop\new_indicadores" + st + ".csv" sub.Popen( r"C:\Program Files\PremiumSoft\Navicat Premium Essentials 12\navicat.exe" ) center_x, center_y, match = location("test.png") gui.doubleClick(center_x, center_y) center_x, center_y, match = location("db.png") gui.doubleClick(center_x, center_y) center_x, center_y, match = location("public.png") gui.doubleClick(center_x, center_y) center_x, center_y, match = location("tables.png") gui.doubleClick(center_x, center_y) gui.press('end') gui.press('end') time.sleep(1) center_x, center_y, match = location("materia_table.png") gui.click(button='right', x=center_x, y=center_y) center_x, center_y, match = location("empty_table.png") gui.click(center_x, center_y) center_x, center_y, match = location("empty_btn.png") gui.click(center_x, center_y) center_x, center_y, match = location("materia_table_active.png") gui.doubleClick(center_x, center_y) center_x, center_y, match = location("import.png") gui.click(center_x, center_y) gui.moveTo(100, 200, 1) gui.moveTo(None, 500, 1) center_x, center_y, match = location("csv_nav.png") gui.click(center_x, center_y) center_x, center_y, match = location("next.png") gui.click(center_x, center_y) center_x, center_y, match = location("import_file.png") gui.click(center_x, center_y) gui.typewrite(path) center_x, center_y, match = location("next.png") gui.click(center_x, center_y) gui.moveTo(100, 200, 1) center_x, center_y, match = location("next_active.png") gui.doubleClick(center_x, center_y) gui.moveTo(100, 200, 1) center_x, center_y, match = location("next_active.png") gui.doubleClick(center_x, center_y) gui.moveTo(100, 200, 1) center_x, center_y, match = location("next_active.png") gui.click(center_x, center_y) gui.moveTo(100, 200, 1) gui.moveTo(None, 500, 1) center_x, center_y, match = location("append.png") gui.click(center_x, center_y) gui.moveTo(100, 200, 1) center_x, center_y, match = location("next.png") gui.click(center_x, center_y) center_x, center_y, match = location("start.png") gui.click(center_x, center_y)
#x = int(input('Введите первое значение X: '))# #y = int(input('Введите второе значение Y: '))# money = int(pyautogui.prompt (text = 'Веди количество: ', title = 'Веди количество: ', default = '')) start1 = pyautogui.prompt (text = 'Выберите кнопку для запуска', title = 'Выберите кнопку', default = '')# При нажатие на первую кнопку pyautogui.alert (text = '2 клика', title = 'нажми Enter', button = 'OK') dans1 = pyautogui.position () # запоминаются 1 данные pyautogui.alert (text = 'перетаскивания с того места где была 1 точка', title = 'нажми Enter', button = 'OK') dans2 = pyautogui.position () # запоминаются 1 данные pyautogui.alert (text = '1 клик', title = 'жМи СуКа Enter', button = 'OK') dans3 = pyautogui.position () # запоминаются 1 данные pyautogui.alert (text = '1 клик', title = 'жМи СуКа Enter', button = 'OK') dans4 = pyautogui.position () # запоминаются 1 данные stop1 = pyautogui.prompt (text = 'Выберите кнопку для остановки', title = 'Выберите кнопку', default = '')# При нажатие на первую кнопку while True: if key.is_pressed( start1 ): # создаем переменную money и присваиваем ей значение 10 while money > 0 or stop1: # Запускаем цикл pyautogui.doubleClick(dans1, duration= 1 ) pyautogui.dragTo(dans2, duration= 1) pyautogui.click(dans3, duration= 1) pyautogui.click(dans4, duration= 1) money -= 1 # Все еще внутри цикла. Уменьшаем на один переменную money else key.is_pressed( stop1):
def graphics_test() -> None: from utility.constants import DATA_PATH, TEST_DATA_PATH import pyautogui x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'map.png'), confidence=0.5) pyautogui.click(x + 160, y + 5) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'labyrinth_new.png'), confidence=0.5) pyautogui.click(x, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'algorithm_new.png'), confidence=0.5) pyautogui.click(x + 150, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'a_star.png'), confidence=0.5) pyautogui.click(x, y) # start and end goals coordinate input pyautogui.click(342, 545) pyautogui.write('17') pyautogui.doubleClick(422, 545) pyautogui.write('9') pyautogui.doubleClick(342, 617) pyautogui.write('4') pyautogui.doubleClick(422, 617) pyautogui.write('5') # update x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'update.png'), confidence=0.5) pyautogui.click(x, y) wait_for('initialised.png') # go into state 1 x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'one.png'), confidence=0.7) pyautogui.click(x, y) # pick colors and other modifications of the map x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'traversables_new.png'), confidence=0.5) pyautogui.click(x - 83, y) time.sleep(0.5) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'orange.png'), confidence=0.9) pyautogui.click(x, y) time.sleep(0.5) # run pyautogui.press('t') wait_for('done.png') time.sleep(0.2) # change trace color x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'trace.png'), confidence=0.8) pyautogui.click(x - 70, y) time.sleep(0.5) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'colour_1.png'), confidence=0.8) pyautogui.click(x, y) time.sleep(1.5) transparent_1 = take_screenshot() time.sleep(1) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'save.png'), confidence=0.7) pyautogui.click(x, y) time.sleep(2) # go to state 2 x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'two.png'), confidence=0.7) pyautogui.click(x, y) transparent_2 = take_screenshot() # change colors time.sleep(0.5) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'traversables_new.png'), confidence=0.5) pyautogui.click(x - 85, y) time.sleep(0.5) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'lime.png'), confidence=0.9) pyautogui.click(x, y) time.sleep(0.5) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'trace.png'), confidence=0.8) pyautogui.click(x - 70, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'lightblue.png'), confidence=0.7) pyautogui.click(x, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'visited.png'), confidence=0.7) pyautogui.click(x - 70, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'colour_2.png'), confidence=0.7) pyautogui.click(x, y) # test restore changes x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'restore.png'), confidence=0.7) pyautogui.click(x, y) time.sleep(1.5) transparent_restored_2 = take_screenshot() x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'one.png'), confidence=0.7) pyautogui.click(x, y) time.sleep(2.5) transparent_restored_1 = take_screenshot() # check if all states are working x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'three.png'), confidence=0.9) pyautogui.click(x, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'four.png'), confidence=0.9) pyautogui.click(x, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'five.png'), confidence=0.9) pyautogui.click(x, y) x, y = pyautogui.locateCenterOnScreen(os.path.join(TEST_DATA_PATH, 'six.png'), confidence=0.9) pyautogui.click(x, y) compare_images(transparent_restored_1, transparent_1, threshold=1) compare_images(transparent_restored_2, transparent_2, threshold=1)
def plot_struc(material): pyautogui.PAUSE = 0.5 handle = WindowEnumerate('SAP Easy Access') print(handle) win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.SetForegroundWindow(handle) pyautogui.moveTo(79, 196) pyautogui.doubleClick() waitforwindow('BOM Plot') pyautogui.hotkey('tab') pyautogui.hotkey('tab') pyautogui.typewrite(str(material)) pyautogui.hotkey('tab') pyautogui.typewrite('3010') pyautogui.hotkey('tab') pyautogui.hotkey('down') pyautogui.hotkey('down') pyautogui.hotkey('tab') pyautogui.hotkey('tab') pyautogui.hotkey('tab') pyautogui.typewrite('1') pyautogui.hotkey('tab') pyautogui.hotkey('space') pyautogui.hotkey('f8') while True: modified_list = [] out = False for i in os.listdir('C:\\Temp'): mtime = os.path.getmtime('C:\\Temp\\' + i) current_time = time.time() if (current_time - mtime) < 60: #check if file was created in last 1 mins modified_list.append(i) print(modified_list) for i in modified_list: if 'isbom' in i: print('should break') out = True break if out: break time.sleep(0.5) time.sleep(1) if not pyautogui.confirm('Continue to DocStructure?') == 'OK': exit() handle = WindowEnumerate('BOM Plot') print(handle) win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.SetForegroundWindow(handle) pyautogui.hotkey('f12') pyautogui.hotkey('f12') modified_list = [] for i in os.listdir('C:\\Temp'): mtime = os.path.getmtime('C:\\Temp\\' + i) current_time = time.time() if (current_time - mtime) < 120: #check if file was created in last 2 mins if "tmp" not in i: modified_list.append(i) #find name of file try: folder_name = modified_list[1].split('.')[0] except: print('Can\'t find files') exit() folder_dir = 'C:\\Users\\atai\\Desktop\\' + folder_name os.mkdir(folder_dir) for i in modified_list: shutil.move('C:\\Temp\\' + i, folder_dir) pyautogui.hotkey('up') pyautogui.hotkey('enter') pyautogui.typewrite(str(material)) pyautogui.hotkey('f8') while True: modified_list = [] out = False for i in os.listdir('C:\\Temp'): mtime = os.path.getmtime('C:\\Temp\\' + i) current_time = time.time() if (current_time - mtime) < 60: #check if file was created in last 1 mins modified_list.append(i) print(modified_list) for i in modified_list: if 'ErrorLog' in i: print('should break') out = True break if out: break time.sleep(0.5) time.sleep(1) modified_list = [] for i in os.listdir('C:\\Temp'): mtime = os.path.getmtime('C:\\Temp\\' + i) current_time = time.time() if (current_time - mtime) < 120: #check if file was created in last 2 mins modified_list.append(i) for i in modified_list: if 'ErrorLog' in i: shutil.move('C:\\Temp\\' + i, folder_dir) time.sleep(1) if not pyautogui.confirm('Continue to SAP?') == 'OK': exit() handle = WindowEnumerate('INVENTOR DOCUMENT STRUCTURE') print(handle) win32gui.ShowWindow(handle, win32con.SW_MAXIMIZE) win32gui.SetForegroundWindow(handle) pyautogui.moveTo(360, 206) pyautogui.click() time.sleep(1) pyautogui.hotkey('down') pyautogui.hotkey('enter') pyautogui.hotkey('enter') waitforwindow('Save As') pyautogui.typewrite(str(material) + '.MHTML') while True: out = False for i in os.listdir('C:\\Users\\atai\\Documents\\SAP\\SAP GUI'): if str(material) in i: out = True break time.sleep(0.5) if out: break shutil.move( 'C:\\Users\\atai\\Documents\\SAP\\SAP GUI\\' + str(material) + '.MHTML', folder_dir)
#find question mark on screen x, y = pyautogui.locateCenterOnScreen('IntialQuestionMark2.png', confidence=.7) #right click it pyautogui.rightClick(x, y, duration=0.2) #inspect element time.sleep(1) a, b = pyautogui.locateCenterOnScreen('InspectElementIcon.png', confidence=.7) pyautogui.click(a, b, duration=0.2) time.sleep(5) print("no sleep") #find blue question mark #click twice on it #cntrl c c, d = pyautogui.locateCenterOnScreen('BlueQuestionPlusSpan.png', confidence=.9) pyautogui.doubleClick((c-50), d, duration=0.2) pyautogui.hotkey('ctrl', 'c') question = pyperclip.paste() print("this is question vvv") print(question) found_question = UsedSentences.query.filter_by(sentence=question).first() if not found_question: newSentence = UsedSentences(sentence=question) db.session.add(newSentence) db.session.commit() response = IrohChatBot.run(question) print(response) #x out of inspect
def run_algorithm(): skip_state = False pyautogui.moveTo(500,400, duration=0.5) pyautogui.rightClick() pyautogui.moveTo(571,575,duration=0.5) pyautogui.click() time.sleep(1.5) # name image pyautogui.typewrite(str(image_num)) time.sleep(1) pyautogui.press('enter') # click on large image pyautogui.moveRel(-150, -250, duration=0.5) pyautogui.rightClick() pyautogui.moveRel(10, 5, duration=0.5) pyautogui.click() time.sleep(4) pyautogui.moveTo(283, 13, duration=1) pyautogui.click() time.sleep(4) # Grab affiliate link text pyautogui.moveTo(186, 90, duration=1) time.sleep(3) pyautogui.doubleClick() time.sleep(3) pyautogui.keyDown('ctrl') pyautogui.press('c') pyautogui.keyUp('ctrl') #copy from clipboard to variable clip.OpenClipboard() afl_link = clip.GetClipboardData() clip.CloseClipboard() if "http" not in afl_link: afl_link = "www.kiitri.com" #copy part link pyautogui.moveTo(361,45) pyautogui.dragTo(443,45,duration=1) pyautogui.keyDown('ctrl') pyautogui.press('c') pyautogui.keyUp('ctrl') #copy from clipboard to variable clip.OpenClipboard() part_link = clip.GetClipboardData() clip.CloseClipboard() #check if part of link is one of last 3 used links if part_link in link_list: renew_state() pyautogui.scroll(-318) # scroll down 318 pixels skip_state = True return skip_state else: link_list[0] = link_list[1] link_list[1] = link_list[2] link_list[2] = part_link print(link_list) #Get text desciption of this item description = run_bs4(afl_link) # close tab pyautogui.keyDown('ctrl') pyautogui.press('w') pyautogui.keyUp('ctrl') #go to pinterest tab pyautogui.moveTo(283, 13, duration=0.5) pyautogui.click() # hover over plus sign pyautogui.moveTo(1192, 90, duration=1) # move to hover over "upload image" pyautogui.moveTo(1192, 156, duration=0.5) pyautogui.click() time.sleep(0.5) # hover over "destination url" pyautogui.moveTo(567, 446, duration=0.5) pyautogui.click() time.sleep(0.5) # paste affiliate link pyautogui.typewrite(afl_link) # upload image I just created pyautogui.moveTo(866, 359) time.sleep(1) pyautogui.click() time.sleep(1) pyautogui.typewrite(str(image_num) + ".jpg") pyautogui.press('enter') time.sleep(1) # post item (Pinterest) pyautogui.moveTo(891, 510, duration=0.2) time.sleep(2) pyautogui.click() time.sleep(2) # add caption (Pinterest) pyautogui.moveTo(432, 525, duration=0.2) pyautogui.click() time.sleep(0.4) pyautogui.typewrite(description) # choose board (Pinterest) pyautogui.moveTo(764,170) pyautogui.doubleClick() pyautogui.typewrite('Best Amazon Finds') time.sleep(2) pyautogui.moveTo(773, 235, duration=0.5) pyautogui.click() time.sleep(3) pyautogui.moveTo(484, 640, duration=0.5) pyautogui.click() time.sleep(3) # jump back to amazon page pyautogui.keyDown('ctrl') pyautogui.press('pgup') pyautogui.keyUp('ctrl') time.sleep(1) # close big image of previous item pyautogui.press('esc') pyautogui.moveTo(773, 235, duration=0.5) return skip_state
def select_ams_refund_payment(date, price, description, reference_number=None): sc.get_m6_coordinates() sites_dictionary = read_pickle_file('sites.p') deposit_options_dictionary = read_pickle_file('deposit_options.p') site = take_screenshot(1517, 1036, 146, 17) if (description == 'ams' and sites_dictionary[site] in ['A1', 'A3']) or \ (description == 'ir' and sites_dictionary[site] in ['A2', 'A3', 'Northstar', 'Breckenridge']) or \ (description == 'sol' and sites_dictionary[site] in ['Northstar', 'Breckenridge']): button = 'payment' else: button = 'insert' if description == 'ams': pyautogui.click(m6[button]) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) x, y = m8['title'] for i in range(9): refund_option = take_screenshot(x + 32, y + 91, 135, 11) try: if deposit_options_dictionary[ refund_option] == 'ams cc refund': pyautogui.click(x + 75, y + 91) break elif i == 8: sys.exit("Couldn't find correct option.") else: y += 13 except KeyError: y += 13 if i == 8: sys.exit("Couldn't find correct option.") elif description == 'ir': if sites_dictionary[site] == 'Timber': correct_option = 'ih cc refund' else: correct_option = 'ir cc refund' pyautogui.click(m6[button]) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) if button == 'payment': pyautogui.click(m8['transaction_code_scroll_bar']) x, y = m8['title'] for i in range(9): refund_option = take_screenshot(x + 32, y + 91, 135, 11) try: if deposit_options_dictionary[refund_option] == correct_option: pyautogui.click(x + 75, y + 91) if correct_option == 'ih cc refund': pyautogui.click(m8['description']) keyboard.send('ctrl + z') keyboard.write('IR CREDIT CARD REFUND') break elif i == 8: sys.exit("Couldn't find correct option.") else: y += 13 except KeyError: y += 13 if i == 8: sys.exit("Couldn't find correct option.") elif description == 'sol': pyautogui.click(m6[button]) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) if button == 'payment' or sites_dictionary[site] in [ 'Cabo', 'A2', 'A3' ]: pyautogui.click(m8['transaction_code_scroll_bar']) pyautogui.click(m8['transaction_code_scroll_bar']) x, y = m8['title'] for i in range(9): refund_option = take_screenshot(x + 32, y + 91, 135, 11) try: if deposit_options_dictionary[ refund_option] == 'sol cc refund': pyautogui.click(x + 75, y + 91) break elif i == 8: sys.exit("Couldn't find correct option.") else: y += 13 except KeyError: y += 13 if i == 8: sys.exit("Couldn't find correct option.") elif description == 'ih': button = 'insert' pyautogui.click(m6[button]) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) x, y = m8['title'] for i in range(9): refund_option = take_screenshot(x + 32, y + 91, 135, 11) try: if deposit_options_dictionary[refund_option] == 'ir cc refund': pyautogui.click(x + 75, y + 91) pyautogui.click(m8['description']) keyboard.send('ctrl + z') keyboard.write('IH REFUND') break elif i == 8: sys.exit("Couldn't find correct option.") else: y += 13 except KeyError: y += 13 if i == 8: sys.exit("Couldn't find correct option.") if button == 'insert': pyautogui.doubleClick(m8['amount']) keyboard.write(price) """attempts = 0 change_description_name = 0 image = None global transaction_code if description == 'ams': if transaction_code > 4: transaction_code = 0 if transaction_code == 0 or transaction_code == 1: pyautogui.click(m6['payment']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_credit_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_credit_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 1 else: transaction_code = 0 pyautogui.click(m8['cancel']) if transaction_code == 0 or transaction_code == 2: attempts = 0 pyautogui.click(m6['payment']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_cc_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_cc_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 2 else: transaction_code = 0 pyautogui.click(m8['cancel']) if transaction_code == 0 or transaction_code == 3: attempts = 0 pyautogui.click(m6['insert']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_cc_ref.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_cc_ref.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 3 else: transaction_code = 0 pyautogui.click(m8['cancel']) if transaction_code == 0 or transaction_code == 4: pyautogui.click(m6['insert']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) attempts = 0 image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_credit_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_credit_refund.png', region=(136, 652, 392, 247)) if image is not None: transaction_code = 4 else: transaction_code = 0 sys.exit("Couldn't find correct choice") elif description == 'ir': if (0 < transaction_code < 5) or transaction_code > 6: transaction_code = 0 if transaction_code == 0 or transaction_code == 5: attempts = 0 pyautogui.click(m6['insert']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ir_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ir_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 5 else: transaction_code = 0 pyautogui.click(m8['cancel']) if transaction_code == 0 or transaction_code == 6: attempts = 0 pyautogui.click(m6['payment']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) pyautogui.click(m8['transaction_code_scroll_bar']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ir_cc_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ir_cc_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 6 else: # Selecting IH Credit Refund and changing it to IR Credit Refund transaction_code = 0 pyautogui.click(m8['cancel']) attempts = 0 pyautogui.click(m6['insert']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ih_credit_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ih_credit_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: change_description_name = 1 else: transaction_code = 0 sys.exit("Couldn't find correct choice") elif description == 'sol': if 0 < transaction_code < 7: transaction_code = 0 if transaction_code == 0 or transaction_code == 7: attempts = 0 pyautogui.click(m6['insert']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) pyautogui.click(m8['transaction_code_scroll_bar']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sol_cc_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sol_cc_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 7 else: transaction_code = 0 pyautogui.click(m8['cancel']) if transaction_code == 0 or transaction_code == 8: attempts = 0 pyautogui.click(m6['insert']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) pyautogui.click(m8['transaction_code_scroll_bar']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sol_credit_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sol_credit_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 8 else: transaction_code = 0 pyautogui.click(m8['cancel']) if transaction_code == 0 or transaction_code == 9: attempts = 0 pyautogui.click(m6['payment']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) pyautogui.click(m8['transaction_code_scroll_bar']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sol_credit_refund.png', region=(136, 652, 392, 247)) while image is None and attempts <= 2: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sol_credit_refund.png', region=(136, 652, 392, 247)) attempts += 1 if image is not None: transaction_code = 9 else: transaction_code = 0 sys.exit("Couldn't find correct choice") pyautogui.click(image) if change_description_name == 1: pyautogui.click(m8['description']) keyboard.send('ctrl + z') keyboard.write('IR CREDIT CARD REFUND') pyautogui.doubleClick(m8['amount']) keyboard.write(price) if (2 < transaction_code < 6) or (6 < transaction_code < 9): pyautogui.doubleClick(m8['amount']) keyboard.write(price)""" pyautogui.doubleClick(m8['reference']) if reference_number is None: keyboard.send('ctrl + v') else: keyboard.write(reference_number) pyautogui.doubleClick(m8['date']) keyboard.write(date) keyboard.send('tab') pyautogui.click(m8['ok']) time.sleep(0.3) pyautogui.click(880, 565) # Clicking yes to the warning that appears pyautogui.click(m6['ok']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_tour_menu.png', region=(514, 245, 889, 566)) while image is None: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_tour_menu.png', region=(514, 245, 889, 566)) x, y = image pyautogui.click(x + 265, y + 475) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_tour_date.png', region=(514, 245, 889, 566)) while image is None: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_tour_date.png', region=(514, 245, 889, 566)) x, y = image pyautogui.click(x - 20, y + 425)
def DoubleClickOnPosition(x=None, y=None): ''' Double clicks on a pixel position on the visible screen determined by x and y coördinates. ''' return pyautogui.doubleClick(x, y)
import pyautogui import time print pyautogui.position() pyautogui.doubleClick(156,187) time.sleep(3) pyautogui.typewrite('Askim') time.sleep(3) pyautogui.click(156,240) pyautogui.typewrite('30 nolu masa 252,00 TL') pyautogui.typewrite('\n')
else: m.moveTo(pos[0] - 15, pos[1]) pos = m.position() elif var == "2": m.click(pos[0], pos[1], button='right') time.sleep(.1) m.position() elif var == "1": m.click(pos[0], pos[1], button='left') m.position() time.sleep(.25) elif var == "3": m.doubleClick() m.position() time.sleep(.1) elif var == "q": m.moveTo(1, 1) pos = m.position() elif var == "p": m.moveTo(1366, 0) pos = m.position() elif var == "t": m.moveTo(683, 0) pos = m.position()
# -*- coding: utf-8 -*- """ Created on Mon Nov 16 00:47:28 2015 @author: Woody """ import pyautogui screenWidth, screenHeight = pyautogui.size() currentMouseX, currentMouseY = pyautogui.position() pyautogui.moveTo(100, 150) pyautogui.click() pyautogui.moveRel(None, 10) # move mouse 10 pixels down pyautogui.doubleClick() pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad) # use tweening/easing function to move mouse over 2 seconds. pyautogui.typewrite('Hello world!', interval=0.25) # type with quarter-second pause in between each key pyautogui.press('esc') pyautogui.keyDown('shift') pyautogui.typewrite(['left', 'left', 'left', 'left', 'left', 'left']) pyautogui.keyUp('shift') pyautogui.hotkey('ctrl', 'c')+'
## brushX = random.randint(1645, 1867) # To determine a random brush ## brushY = random.randint(253, 326) ##pyautogui.doubleClick(1645,253) # Select the brush loopcount = 400 # Specify the number of brush strokes i = 1 while i < 40: # For painting in the first quadrant # 2) Select color colorSelect = random.randint(1, 5) # Randomly select from among 5 colors if colorSelect == 1: # Select first color pyautogui.doubleClick(White) elif colorSelect == 2: # Select second color pyautogui.doubleClick(LightGrey) elif colorSelect == 3: # Select third color pyautogui.doubleClick(DarkGrey) elif colorSelect == 4: # Select fourth color pyautogui.doubleClick(Black) elif colorSelect == 5: # Select fifth color pyautogui.doubleClick(LightGrey) thickness = random.randint(10, 100) # Determine a random width for the brush
def startHollyQuests(): # click on Play logging.info("Looking for Play button...") while not getGameStatus(PLAY_PAGE): pyautogui.click(PLAY_BUTTON_COORDS, duration=0.25) time.sleep(5) logging.info("Clicked on Play button.") pyautogui.click(CHAR_STORY_COORDS, duration=0.25) logging.info("Clicked on Character Story button.") while not getGameStatus(CHAR_STORY_PAGE): time.sleep(5) pyautogui.click(CHAR_STORY_COORDS, duration=0.25) pyautogui.click(CHAR_STORY_UP_ARROW_COORDS, duration=0.25) logging.info("Clicked on Character Story Up button.") time.sleep(2) pyautogui.click(CHAR_STORY_HOLLY_COORDS, duration=0.25) logging.info("Clicked on Holly Character Story button.") time.sleep(2) pyautogui.click(CHAR_STORY_EP1_COORDS, duration=0.25) time.sleep(2) while not getGameStatus(BEGIN_STORY): pyautogui.click(CHAR_STORY_EP1_COORDS, duration=0.25) time.sleep(2) pyautogui.click(CHAR_STORY_BEGIN_STORY_COORDS, duration=0.25) time.sleep(2) pyautogui.click(PARTY_BEGIN_STORY_COORDS, duration=0.25) logging.info("Begin story...") time.sleep(2) # check if enough food if getGameStatus(FOOD_NOT_ENOUGH): pyautogui.click(CLOSE_NO_FOOD_BUTTON_COORDS, duration=0.25) logging.info("No food. Delay for 30 mins.") time.sleep(30 * 60) # wait for 30 mins logging.info("Wakes up.") pyautogui.click(PARTY_BEGIN_STORY_COORDS, duration=0.25) time.sleep(7) while not getGameStatus(QUEST_ONGOING_PAGE): time.sleep(4) pyautogui.click(FAST_FORWARD_BUTTON_COORDS) logging.info("Clicked on Fast Forward button.") # no way to check if it's actually clicked time.sleep(2 * 60) # wait 4 mins pyautogui.doubleClick(FAST_FORWARD_BUTTON_COORDS) # prevent screen saver from kicking in time.sleep(1 * 60) # wait 2 mins quest_running = True while quest_running: # random mouse move to prevent screen saver # pyautogui.moveTo(random.randint(1, 10), random.randint(1, 10), 2) pyautogui.doubleClick(FAST_FORWARD_BUTTON_COORDS) time.sleep(10) quest_running = getGameStatus(QUEST_ONGOING_PAGE) if not quest_running: time.sleep(3) quest_running = getGameStatus(QUEST_ONGOING_PAGE) # check again to confirm while not getGameStatus(CEO_OFFICE_PAGE): pyautogui.click(FAST_FORWARD_BUTTON_COORDS, duration=0.25) # continue clicking until back to CEO Office logging.info("Clicked to continue.") time.sleep(2)
def connect_to_local_runtime(user_choice): try: # import chromedriver_binary if user_choice == "ClointFusion Labs (Public)": colab_url = "https://accounts.google.com/signin/v2/identifier?authuser=0&hl=en&continue=https://colab.research.google.com/github/ClointFusion/ClointFusion/blob/master/ClointFusion_Labs.ipynb" #https://colab.research.google.com/github/ClointFusion/ClointFusion/blob/master/ClointFusion_Labs.ipynb" # colab_url = "https://colab.research.google.com/github/ClointFusion/ClointFusion/blob/master/ClointFusion_Labs.ipynb" # elif user_choice == "ClointFusion Lite (Interns Only)": # #Extract encrypted version of ClointFusion_Lite to a specific folder and in Colab import that folder # colab_url = 'https://accounts.google.com/signin/v2/identifier?authuser=0&hl=en&continue=https://colab.research.google.com/drive/11MvoQfNFXJqlXKcXV1LBVUE98Ks48M_a' elif user_choice == "ClointFusion Starter (Hackathon)": colab_url = 'https://accounts.google.com/signin/v2/identifier?authuser=0&hl=en&continue=https://colab.research.google.com/drive/1G9mh58z8AbWqBit2TC4Wgg6p_eHPvUJB' user_data_path = "C:\\Users\\{}\\AppData\\Local\\Google\\Chrome\\User Data".format(os.getlogin()) modify_file_as_text(user_data_path + '\\Default\\Preferences', 'crashed', 'false') options = Options() options.add_argument("--start-maximized") options.add_experimental_option('excludeSwitches', ['enable-logging']) if os_name == "windows": options.add_argument("user-data-dir=C:\\Users\\{}\\AppData\\Local\\Google\\Chrome\\User Data".format(os.getlogin())) elif os_name == "darwin": options.add_argument("user-data-dir=/Users/{}/Library/Application/Support/Google/Chrome/User Data".format(os.getlogin())) options.add_argument(f"profile-directory=Default") browser_driver = webdriver.Chrome(ChromeDriverManager().install(), options=options) browser.set_driver(browser_driver) browser.go_to(colab_url) chrome = gw.getWindowsWithTitle('Google Chrome')[0] chrome.activate() # pg.doubleClick(pg.size()[0]/2,pg.size()[1]/2) # kb.press_and_release('esc') # kb.press_and_release('esc') try: browser.wait_until(browser.Text("Code").exists,timeout_secs=6) except :#selenium_wrappers.common.exceptions.TimeoutException: try: browser.click(email) except: browser.write(email, into='Email or phone') browser.click('Next') time.sleep(0.5) browser.write(passwd, into='Enter your password') browser.click('Next') time.sleep(0.5) browser.wait_until(browser.Text("Code").exists,timeout_secs=240) # kb.press_and_release('esc') # time.sleep(0.2) # pg.press(ESCAPE) # time.sleep(0.2) # press(ESCAPE) # time.sleep(0.2) if FIRST_TIME: #create short-cut browser.press(browser.CONTROL + 'mh') time.sleep(1) v = S("//input[@id='pref_shortcut_connectLocal']") browser.write('',v) browser.press(browser.CONTROL + '1') time.sleep(0.5) browser.click("SAVE") time.sleep(1) #use short-cut browser.press(browser.CONTROL + '1') time.sleep(1) # pg.alert("HKHR") pg.doubleClick(pg.size()[0]/2,pg.size()[1]/2) time.sleep(1) if FIRST_TIME: # kb.press_and_release('SHIFT+TAB') pg.hotkey('SHIFT', 'TAB') time.sleep(0.5) # kb.press_and_release('SHIFT+TAB') pg.hotkey('SHIFT', 'TAB') time.sleep(0.5) # kb.press_and_release('SHIFT+TAB') pg.hotkey('SHIFT', 'TAB') time.sleep(0.5) pg.write("http://localhost:8888") # kb.write("http://localhost:8888") time.sleep(2) # click("CONNECT") # kb.press_and_release('TAB') pg.hotkey('TAB') time.sleep(0.5) # pg.alert(1) # kb.press_and_release('TAB') pg.hotkey('TAB') time.sleep(0.5) # pg.alert(2) else: # kb.press_and_release('SHIFT+TAB') pg.hotkey('SHIFT', 'TAB') time.sleep(0.5) browser.press(browser.ENTER) time.sleep(2) # try: # img = "Restore_Bubble.PNG" # pos = pg.locateOnScreen(img, confidence=0.8) #region= # pg.alert(pos) # pg.click(*pos) # except: # pass pg.alert("Ready ! Google Colab is now connected with your Local Runtime.\n\nPlease click 'OK' & you are all set to work on ClointFusion Colabs...") except Exception as ex: print("Error in connect_to_local_runtime="+str(ex)) exc_type, exc_value, exc_tb = sys.exc_info() pg.alert(traceback.format_exception(exc_type, exc_value, exc_tb,limit=None, chain=True)) pg.alert("Error in connect_to_local_runtime="+str(ex)) connect_to_local_runtime()
#! python3 ''' A program that logs out from the current windows 10 user ''' import pyautogui pyautogui.click(25, 1005, duration = 1) pyautogui.click(25, 768, duration = 1) pyautogui.doubleClick(25, 595, duration = 1)
def leftClick(posX, posY): pyautogui.doubleClick(x=posX, y=posY, button='left') pyautogui.mouseDown() pyautogui.mouseUp()
import time from pymongo import MongoClient app = Flask(__name__) client = MongoClient('localhost', 27017) db = client.dbhomework driver = webdriver.Chrome('C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe') driver.get('https://mycompany.hyundaicard.com') pyautogui.PAUSE = 1 pyautogui.FAILSAFE = True pyautogui.moveTo(1173,350,1) pyautogui.doubleClick(x=1173,y=350, button='left') #현대카드 홈페이지 내에 메뉴 화면 없애기 pyautogui.moveTo(33,844,1) pyautogui.click(x=33,y=844,button='left') #아이디 화면 띄우기 pyautogui.moveTo(153,564,1) pyautogui.doubleClick(x=153,y=564, button='left') driver.find_element_by_id("corp_web_mbr_id").send_keys('kuksan88') time.sleep(10) # My account pyautogui.click(x=478,y=230, button='left', duration=1) # 카드이용 내역
def window1(): return pyautogui.locateOnScreen('okno.bmp', grayscale=True, confidence=0.9) confirm1 = pyautogui.confirm('Начинаем точить?', 'Clicker v1') if confirm1 == 'OK': print('Ищем окно заточки') print(window1()) button1svitok() while button1svitok() != None: if window1() == None: print('Окно заточки не открыто, открываю') window1() #ищем окно заточки pyautogui.moveTo(button1svitok(), duration=0.2) #идем к свитку sleep(0.1) pyautogui.doubleClick() #открываем свиток sleep(2) if window1() != None: continue else: print('Окно заточки найдено') pyautogui.moveTo(1080, 400) #Убираем курсор sleep(0.1) pyautogui.moveTo(button2item()) if button2item() != None: print('Нашел шмотку') button3kuda() #Ищем куда тащить if button3kuda() != None: print('Нашел куда тащить, тащу') pyautogui.dragTo(button3kuda(), button='left',
def do_it(self,body): try: if body != None: head = body[:4] body = body[4:] if head == 'MOUS': #MOUSE MOVE EVENT mxy = body.split('|') self.mous.move(int(mxy[0]),int(mxy[1])) #pyautogui.moveTo(int(mxy[0]),int(mxy[1])) elif head == 'MCLK': #MOUSE CLICK EVENT mxy = body.split('|') if mxy[2] == 'DCLK': # DOUBLE CLICK if mxy[3] == '1': pyautogui.doubleClick(int(mxy[0]),int(mxy[1]),button='left') elif mxy[3] == '2': pyautogui.doubleClick(int(mxy[0]),int(mxy[1]),button='right') elif mxy[2] == 'SCLK': #SINGLE CLICK if mxy[3] == '1': pyautogui.click(int(mxy[0]),int(mxy[1]),button='left') elif mxy[3] == '2': pyautogui.click(int(mxy[0]),int(mxy[1]),button='right') elif mxy[2] == 'DOWN': #MOUSE PRESS if mxy[3] == '1': pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='left') elif mxy[3] == '3': pyautogui.mouseDown(int(mxy[0]),int(mxy[1]),button='right') elif mxy[3] == '4': #SCROLL DOWN pyautogui.scroll(-5,x=int(mxy[0]),y=int(mxy[1])) elif mxy[2] == 'UP': #MOUSE RELEASE if mxy[3] == '1': pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='left') elif mxy[3] == '3': pyautogui.mouseUp(int(mxy[0]),int(mxy[1]),button='right') elif mxy[3] == '4': #SCROLL UP pyautogui.scroll(5,x=int(mxy[0]),y=int(mxy[1])) elif head == "KCLK": #KEYBOARD EVENT key_ev = body.split('|') if key_ev[0] == 'DOWN': pyautogui.keyDown(key_ev[1]) elif key_ev[0] == "UP": pyautogui.keyUp(key_ev[1]) elif key_ev[0] == "PRES": pyautogui.press(key_ev[1]) elif head == 'CLIP': # CLIP BOARD EVENT if body[:4] == 'COPY': #send local clipboard to remote lclip = pyperclip.paste() screen_output_q.put_nowait(self.controler+lclip) elif body[:4] == 'PAST': #receive remote clipboad data = body[4:] pyperclip.copy(data) return True except Exception as e: print "INPUT CONTROL ERROR",e return False
import locateScreen mousePos = { "1" : [(756, 348),(255, 255, 255)], "2" : [(719, 854),(157, 162, 246)], "3" : [(822, 252),(255, 255, 255)], } formData = [ {'name':'Alic', 'fear':'f**k', 'source':1, 'robocop':1, 'comments':'say hi'}]; pyautogui.PAUSE = 0.5 webbrowser.open('https://docs.google.com/forms/d/1A39NpQYMN8OOG-_lqDLFQb2h1SiHhCxPh0udtDEy2rU/viewform'); p = locateScreen.locate('firefox.png'); if not p is None: pyautogui.doubleClick(p[0], p[1]); for j in range(3): for person in formData: submit = mousePos["2"]; while not pyautogui.pixelMatchesColor(submit[0][0], submit[0][1], submit[1]): time.sleep(0.5); nameFile = mousePos["1"]; pyautogui.click(nameFile[0][0], nameFile[0][1]); pyautogui.typewrite(person['name'] + '\t'); pyautogui.typewrite(person['fear'] + '\t'); pyautogui.typewrite(['down'] * person['source'] + ['\t']); pyautogui.typewrite(['right'] * person['robocop'] + ['\t']); pyautogui.typewrite(person['comments'] + '\t'); pyautogui.press('enter'); time.sleep(3); otherLink = mousePos["3"];