def buscar_campo_id(): msg = '' pyautogui.PAUSE = 0.5 pyautogui.FAILSAFE = False pyperclip.copy('') dondeEstaElCampoID = pyautogui.locateOnScreen('operator-id-field.png') if dondeEstaElCampoID is None: msg = 'El campo de OPERATOR-ID no fue encontrado' return (False, msg) else: campoIDPos = list(dondeEstaElCampoID) #print campoIDPos centrocampoID = pyautogui.center(campoIDPos) #print centrocampoID pyautogui.moveTo(centrocampoID) pyautogui.click(None,None,2) pyautogui.typewrite('operador1') pyautogui.press('enter') pyautogui.press('enter') pyautogui.press('enter') return (True, msg)
def buscar_test(): msg = '' pyautogui.PAUSE = 0.5 pyautogui.FAILSAFE = False pyperclip.copy('') findTest = pyautogui.locateOnScreen('buscar-tests.png') if findTest is None: msg = 'La opcion LOGIN TO CONSOLE no esta seleccionada' return (False, msg) #exit(0) else: testPos = list(findTest) #print testPos centroTest = pyautogui.center(testPos) print centroTest pyautogui.moveTo(centroTest) pyautogui.click(None,None,1) pyautogui.moveRel(10, 30) pyautogui.click(None,None,1) #pyautogui.screenshot('menu-screen2.png') #pyautogui.click(None,None,1) #pyautogui.screenshot('menu-screen1.png') findLogin = pyautogui.locateOnScreen('imagenx.png') print findLogin return (True, msg)
def performAction( yp, rc, bc, perform): if perform : cursor[0] = 4*(yp[0]-110) cursor[1] = 4*(yp[1]-120) if yp[0]>110 and yp[0]<590 and yp[1]>120 and yp[1]<390: pyautogui.moveTo(cursor[0],cursor[1]) elif yp[0]<110 and yp[1]>120 and yp[1]<390: pyautogui.moveTo( 8 , cursor[1]) elif yp[0]>590 and yp[1]>120 and yp[1]<390: pyautogui.moveTo(1912, cursor[1]) elif yp[0]>110 and yp[0]<590 and yp[1]<120: pyautogui.moveTo(cursor[0] , 8) elif yp[0]>110 and yp[0]<590 and yp[1]>390: pyautogui.moveTo(cursor[0] , 1072) elif yp[0]<110 and yp[1]<120: pyautogui.moveTo(8, 8) elif yp[0]<110 and yp[1]>390: pyautogui.moveTo(8, 1072) elif yp[0]>590 and yp[1]>390: pyautogui.moveTo(1912, 1072) else: pyautogui.moveTo(1912, 8) if rc[0]!=-1 and bc[0]!=-1: if abs(rc[0]-bc[0])<35 and abs(rc[1]-bc[1])<20: pyautogui.click(button = 'left')
def _saveImage(imageWindow): """ Brings up the save image dialog, presses the Save button, and then closes the dialog. Parameters ---------- imageWindow: The image window which has already been located. """ pyautogui.rightClick(x=imageWindow[0], y=imageWindow[1]) pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('down') pyautogui.press('return') saveButton = ImageUtil.locateCenterOnScreen( 'test_images/saveImageButton.png') assert saveButton != None pyautogui.click( x=saveButton[0], y=saveButton[1] ) closeButton = ImageUtil.locateCenterOnScreen('test_images/closeButton.png') assert closeButton != None pyautogui.click( x=closeButton[0], y=closeButton[1] )
def move_arena(): time.sleep(3) pyautogui.moveTo(*area_select_open) pyautogui.moveTo(*area_select_arena) pyautogui.click() pyautogui.moveTo(area_middle) pyautogui.click()
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 clickAndReturnMouse(img): orig_x,orig_y = pyautogui.position() pyautogui.moveTo(img['points'][0]['center'][0],img['points'][0]['center'][1]) pyautogui.click() logging.info('CLICK') pyautogui.moveTo(orig_x, orig_y) return
def clickAndReturnMouseCoords(coords): orig_x,orig_y = pyautogui.position() pyautogui.moveTo(coords[0],coords[1]) pyautogui.click() logging.info('CLICK') pyautogui.moveTo(orig_x, orig_y) return
def test_animatorReverse(cartavisInstance, cleanSlate): """ Test the Animator reverse setting. """ i = cartavisInstance.getImageViews() a = cartavisInstance.getAnimatorViews() # Load an image i[0].loadFile(os.getcwd() + '/data/N15693D.fits') # Get the last channel value (should be the number of channels - 1) lastChannel = i[0].getChannelCount() - 1 # Open animator settings _openAnimatorSettings() # Click the reverse radio button reverseButton = ImageUtil.locateCenterOnScreen('test_images/reverseButton.png') assert reverseButton != None pyautogui.click( x=reverseButton[0], y=reverseButton[1]) # Set the image to the last channel value a[0].setChannel( lastChannel ) # Click the forward animate button on the tape deck _animateForward() time.sleep(2) assert a[0].getChannelIndex() < lastChannel _stopAnimation() # Close animator settings _openAnimatorSettings()
def makeOrder(orderType): """Does the mouse clicks needed to create an order. The orderType parameter has the value of one of the ONIGIRI, GUNKAN_MAKI, CALIFORNIA_ROLL, SALMON_ROLL, SHRIMP_SUSHI, UNAGI_ROLL, DRAGON_ROLL, COMBO constants. The INVENTORY global variable is updated in this function for orders made. The return value is None for a successfully made order, or the string of an ingredient constant if that needed ingredient is missing.""" global ROLLING_COMPLETE, INGRED_COORDS, INVENTORY # wait until the mat is clear. The previous order could still be there if the conveyor belt has been full or the mat is currently rolling. while time.time() < ROLLING_COMPLETE and pyautogui.locateOnScreen(imPath('clear_mat.png'), region=(GAME_REGION[0] + 115, GAME_REGION[1] + 295, 220, 175)) is None: time.sleep(0.1) # check that all ingredients are available in the inventory. for ingredient, amount in RECIPE[orderType].items(): if INVENTORY[ingredient] < amount: logging.debug('More %s is needed to make %s.' % (ingredient, orderType)) return ingredient # click on each of the ingredients for ingredient, amount in RECIPE[orderType].items(): for i in range(amount): pyautogui.click(INGRED_COORDS[ingredient], duration=0.25) INVENTORY[ingredient] -= 1 findAndClickPlatesOnBelt() # get rid of any left over meals on the conveyor belt, which may stall this meal from being loaded on the belt pyautogui.click(MAT_COORDS, duration=0.25) # click the rolling mat to make the order logging.debug('Made a %s order.' % (orderType)) ROLLING_COMPLETE = time.time() + 1.5 # give the mat enough time (1.5 seconds) to finish rolling before being used again
def findAndClickPlatesOnBelt(): """Find any plates on the conveyor belt that can be removed and click on them to remove them. This will get rid of excess orders.""" for color in ('pink', 'blue', 'red'): result = pyautogui.locateCenterOnScreen(imPath('%s_plate_color.png' % (color)), region=(GAME_REGION[0] + 343, GAME_REGION[1] + 300, 50, 100)) if result is not None: pyautogui.click(result) logging.debug('Clicked on %s plate on belt at X: %s Y: %s' % (color, result[0], result[1]))
def onscreen_keyboard_input(keyboard,input_str,sleep_time =0.5): try: pyautogui.moveTo(keyboard_in["begin1"]) for i in list(input_str): if keyboard.has_key(i): pyautogui.click(keyboard[i]) time.sleep(sleep_time) elif i.isupper(): i = i.lower() if keyboard.has_key(i): #pyautogui.click(keyboard_in["begin1"]) pyautogui.click(keyboard["left_shift"]) #pyautogui.click(keyboard_in["begin1"]) pyautogui.click(keyboard[i]) #pyautogui.click(keyboard_in["begin1"]) time.sleep(sleep_time) else: #pyautogui.click(keyboard_in["begin1"]) pyautogui.click(keyboard["left_shift"]) #pyautogui.click(keyboard_in["begin1"]) pyautogui.click(keyboard[shift_keyboard[i]]) #pyautogui.click(keyboard_in["begin1"]) time.sleep(sleep_time) #except: except Exception,e: print("have issue. exit input string") msg = "onscreen_keyboard_input funcation:" + e print time.ctime(),msg logging.info(msg)
def output_doulist(input_list): # 1. find button and change focus in browser button_pos = pyautogui.locateOnScreen('output/add_button.png') if not button_pos: # no valid button print '没有找到有效的"添加内容"按钮, 请检查后再次导出.' return elif len(list(pyautogui.locateAllOnScreen('output/add_button.png'))) > 1: # more than one valid button print '屏幕中有多个有效的"添加内容"按钮, 请检查后再次导出.' return else: # valid input: only one button available # remaining issue: the picture is not alwas found in screen...that's strange. pyautogui.click(button_pos) for i in input_list: # 2. press button time.sleep(4) pyautogui.click(button_pos) # 3. write link time.sleep(2) pyautogui.typewrite(i) pyautogui.press('enter') # 4. add to Doulist time.sleep(2) pyautogui.press('tab') pyautogui.press('tab') pyautogui.press('tab') pyautogui.press('enter') print 'iDoulist: 书籍列表已被添加到屏幕上的豆列中.'
def moveNClickIfFindIt (**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.click() pyautogui.moveTo(10, 10)
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 incontent_noauto(i): b.open(i,new=new) time.sleep(3) scroll_down() time.sleep(1) pyautogui.press('s') time.sleep(2) pyautogui.press('m')#mute the ad pyautogui.press('v')#un-mute full_screen(i) time.sleep(1) pyautogui.press('esc') #pyautogui.click(810,409) #pyautogui.click(810,409) #pyautogui.click() pyautogui.click() pyautogui.press('s') pyautogui.press('r') click_through(i) pyautogui.press('p')#pause the ad time.sleep(1) pyautogui.press('r')#resume the ad pyautogui.click() time.sleep(15) scroll_up() #os.system(bashCommand) close_tab()
def attack(): # 使用match修改 global AttackPos sleep(2) p.click() # sleep(0.001) p.moveTo(AttackPos[0], AttackPos[1]) p.click(clicks=50)
def test_animatorWrap(cartavisInstance, cleanSlate): """ Test that the Animator wrap setting returns to the first channel value after animating the last channel. """ i = cartavisInstance.getImageViews() a = cartavisInstance.getAnimatorViews() # Load an image i[0].loadFile(os.getcwd() + '/data/N15693D.fits') # Get the last channel value (should be the number of channels - 1) lastChannel = i[0].getChannelCount() - 1 # Open animator settings _openAnimatorSettings() # Click the wrap radio button wrapButton = ImageUtil.locateCenterOnScreen('test_images/wrapButton.png') assert wrapButton != None pyautogui.click( x=wrapButton[0], y=wrapButton[1]) # Set the image to the last channel value a[0].setChannel( lastChannel ) # Click the increment button and get the current channel _getNextValue() assert a[0].getChannelIndex() == 0 _getNextValue() assert a[0].getChannelIndex() == 1 # Close animator settings _openAnimatorSettings()
def clickAndReturnMouse_point(point): orig_x,orig_y = pyautogui.position() pyautogui.moveTo(point['center'][0],point['center'][1]) pyautogui.click() logging.info('CLICK') pyautogui.moveTo(orig_x, orig_y) return
def test_channelAnimatorChangeImage(cartavisInstance, cleanSlate): """ Test that the Channel Animator will update when the window image is switched. """ i = cartavisInstance.getImageViews() a = cartavisInstance.getAnimatorViews() # Load an image i[0].loadFile(os.getcwd() + '/data/N15693D.fits') # Load a different image i[0].loadFile(os.getcwd() + '/data/aH.fits') # Get the upper spinbox value of the second image # Go to the last value and get the channel value lastValueButton = ImageUtil.locateCenterOnScreen('test_images/lastValueButton.png') pyautogui.click( x=lastValueButton[0], y=lastValueButton[1]) time.sleep(2) upperBound = a[0].getChannelIndex() # Change back to the first image and get the upper spinbox value a[0].setImage(0) pyautogui.click( x=lastValueButton[0], y=lastValueButton[1]) newUpperBound = a[0].getChannelIndex() assert upperBound != newUpperBound
def down_a_level(self): """Holds down and presses alt to jump down""" time.sleep(1) pyautogui.mouseDown(self.DOWN) time.sleep(2.5) pyautogui.click(self.ALT) pyautogui.mouseUp()
def buscar_campo_serial(serial_number): msg = '' pyautogui.PAUSE = 0.5 pyautogui.FAILSAFE = False pyperclip.copy('') dondeEstaElCampoSerial = pyautogui.locateOnScreen('operator-id-field.png') if dondeEstaElCampoSerial is None: msg = 'El campo de SERIAL NUMBER no fue encontrado' return (False, msg) else: campoSerialPos = list(dondeEstaElCampoSerial) #print campoSerialPos centrocampoSerial = pyautogui.center(campoSerialPos) #print centrocampoSerial pyautogui.moveTo(centrocampoSerial) pyautogui.click(None,None,2) #pyautogui.typewrite('C3WB4E768226230') pyautogui.typewrite(serial_number) pyautogui.press('enter') #pyautogui.press('enter') #pyautogui.press('enter') return (True, msg)
def GetShitDone(): "Tis function looks after the moon and get shit done" pos = pyautogui.locateOnScreen('moon.png') if (pos != None): x, y = pyautogui.center(pos) print(time.ctime(), 'Found moon @ x:', x , ' y:', y) pyautogui.click(x, y+75) time.sleep( 1.5 ) pos = pyautogui.locateOnScreen('horn.png') if (pos != None): x, y = pyautogui.center(pos) print(time.ctime(), 'make horn @ x:', x , ' y:', y) pyautogui.click(x, y+75) return pos = pyautogui.locateOnScreen('pot.png') if (pos != None): x, y = pyautogui.center(pos) print(time.ctime(), 'make pot @ x:', x , ' y:', y) pyautogui.click(x, y+75) return pos = pyautogui.locateOnScreen('kohl.png') if (pos != None): x, y = pyautogui.center(pos) print(time.ctime(), 'make kohl @ x:', x , ' y:', y) pyautogui.click(x, y) return pos = pyautogui.locateOnScreen('close.png') if (pos != None): x, y = pyautogui.center(pos) print(time.ctime(), 'exit @ x:', x , ' y:', y) pyautogui.click(x, y) return return
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 navigateGameWindow(): """Get the initial focus on the game window and mute the game, getting ready to play.""" # Get focus on the game by clicking the center of the game region pyautogui.click(GAME_CENTER[0], GAME_CENTER[1], duration=1) # Mute game (it helps too because it disables some in-game effects :-p) pyautogui.press('m')
def real_change(lat_lng_string): if js_develop_mode: return last_pos = pyautogui.position() lat_lng = dict(re.findall(r'([latng]{3})\=([\d\.\-]+)', lat_lng_string)) rewrite_gpx(lat_lng) for pos in gps_button_pos, gpx_file_pos, last_pos: pyautogui.click(*pos)
def hangup(): location = pyautogui.locateOnScreen(image('hangup.png')) if location is None: print 'Could not find hangup button' return False location_x, location_y = pyautogui.center(location) pyautogui.click(location_x, location_y) time.sleep(3)
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 click(mouv): x=0 y=0 for pos in mouv.tabMouvementDoigts[0]: x+=pos[0]/len(mouv.tabMouvementDoigts[0]) y+=pos[1]/len(mouv.tabMouvementDoigts[0]) print "click",x,y pyautogui.click(x=x,y=y)
import pyautogui pyautogui.screenshot('.\\GUI\\example.png') # print(pyautogui.locateOnScreen('.\\GUI\\calc7key.png')) # This grab the center of the image aka 7 of the calculator location = pyautogui.locateCenterOnScreen('.\\GUI\\calc7key.png') pyautogui.moveTo(location, duration=1) pyautogui.click(location)
pyautogui.FAILSAFE = True #启动自动防止故障功能 print(pyautogui.size()) width,height = pyautogui.size() for i in range(2): pyautogui.moveTo(100,100,duration=0.25) #根据屏幕绝对位置移动到位置(100,100),花费0.25秒 pyautogui.moveTo(200,100,duration=0.25) pyautogui.moveTo(200,200,duration=0.25) pyautogui.moveTo(300,200,duration=0.25) pyautogui.moveTo(300,300,duration=0.25) for i in range(2): pyautogui.moveRel(100,0,duration=0.25)#根据当前位置移动(100,0),花费0.25秒 pyautogui.moveRel(-100,0,duration=0.25)#根据当前位置移动(-100,0),花费0.25秒 pyautogui.position() #获取鼠标位置 pyautogui.click(100,50,button='left') #在(100,50)位置左击 pyautogui.click(100,50,button='right') #在(100,50位置右击) pyautogui.mouseDown() #鼠标下移,参数同上 pyautogui.mouseUp() #鼠标上移,参数同上 pyautogui.dragTo() #绝对位置拖动,参数同上 pyautogui.dragRel() #相对位置拖动,参数同上 pyautogui.scroll(200) #滚动屏幕,参数同上 pyautogui.screenshot() #获取屏幕快照,参数同上 #屏幕快照分析 im = pyautogui.screenshot() im.getpixel(50,200) pyautogui.pixelMatchesColor(50,200,(130,135,144))#匹配像素点RGB颜色,返回True\False0lo pyautogui.typewrite('Hello world!')
# while True: # cur_clip = clip.paste() # if cur_clip != last_clip: # print("clip changed") # new_clip = interpret_picard(cur_clip) # clip.copy(new_clip) # last_clip = new_clip # print("updated clip") # else: # last_clip = cur_clip # time.sleep(0.05) while True: # wait until ctrl+p key keyboard.wait("ctrl+p") # do the thing gui.rightClick() time.sleep(0.2) gui.moveRel(10, 150) gui.click() time.sleep(0.3) keyboard.send("ctrl+a") time.sleep(0.2) keyboard.send("ctrl+c") time.sleep(0.2) new_clip = interpret_picard(clip.paste()) clip.copy(new_clip) keyboard.send("ctrl+v") time.sleep(0.2) keyboard.send("enter")
#Wait time.sleep(6.8) #Send Command to MMDAgent pgui.typewrite('3') #func end --- #URLs --- url = "https://transit.goo.ne.jp/unkou/train/kantou/" res = req.urlopen(url) soup = BeautifulSoup(res, "html.parser") #Click MMDAgent --- pgui.click(10, 10) #Register Routes --- reg_list = { "横浜線", "京浜東北根岸線", "南武線[川崎~立川]", "中央線(快速)[東京~高尾]", "山手線", "八高川越線[八王子~川越]", "京王相模原線", "京王線", "小田急小田原線", "小田急江ノ島線", "小田急多摩線", "東急田園都市線" } #Get Designated Data --- #Get Route Name name_list = soup.select("ul.traininfo a") #Get Status Att sts_list = soup.select(".status") #Combine --- info_list = [name_list, sts_list]
def restart(): # print('restart') # mouse.position = (1580, 970) # mouse.click(Button.left, 1) # pyautogui.click(1580, 970)
'robocop': 5, 'comments': 'Protect the innocent. Serve the public trust. Uphold the law.'}, ] pyautogui.PAUSE = 0.5 for person in formData: # Give the user a chance to kill the script. print('>>> 5 SECOND PAUSE TO LET USER PRESS CTRL-C <<<') time.sleep(5) # Wait until the form page has loaded. while not pyautogui.pixelMatchesColor(submitButton[0], submitButton[1], submitButtonColor): time.sleep(0.5) print('Entering %s info...' % (person['name'])) pyautogui.click(nameField[0], nameField[1]) # Fill out the Name Field. pyautogui.typewrite(person['name'] + '\t') # Fill out the Greatest Fear(s) field. pyautogui.typewrite(person['fear'] + '\t') # Fill out the Source of Wizard Powers field. if person['source'] == 'wand': pyautogui.typewrite(['down', '\t']) elif person['source'] == 'amulet': pyautogui.typewrite(['down', 'down', '\t']) elif person['source'] == 'crystal ball': pyautogui.typewrite(['down', 'down', 'down', '\t']) elif person['source'] == 'money':
try: from PIL import Image except ImportError: import Image import pytesseract import pyscreenshot as ImageGrab pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe' door = "THIS DOOR IS LOCKED" import pyautogui a = 1000 while a <= 9999: pyautogui.press("e") im = ImageGrab.grab(bbox=(750, 377, 1170, 417)) # This is locked im.save('door_locked.png') # saving the shit name = pytesseract.image_to_string(Image.open('door_locked.png')) if (door != name): break pyautogui.click(959, 538) #write pyautogui.write('%a' % (a)) pyautogui.click(960, 616) #ACCEPT print('%a\n' % (a)) a += 1
img_array = [] for img in images: image = cv2.imread(img) img_array.append(image) # region_full=(400,300,750,450) # region_equal=(600,300,450,250) region_full = (300, 500, 450, 450) region_equal = (300, 370, 450, 250) play_button = snp.locateOnScreen('pic\play_button.JPG', region=region_full) while play_button == None: play_button = snp.locateOnScreen('pic\play_button.JPG', region=region_full) p = play_button if p != None: pyautogui.click(p[0] + p[2] // 2, p[1] + p[3] // 2) # 重新執行 while True: results = snp.locateOnScreen(results_pic, region=region_equal) equal = snp.locateOnScreen(equal_pic, region=region_equal) answer_box = snp.locateOnScreen(answer_box_pic, region=region_equal) if results != None: results_resion_list = list(results) results_x = results_resion_list[0] results_y = results_resion_list[1] pyautogui.click(results_x - 210, results_y + 190) if equal != None and answer_box != None: # print('equal',equal) equal_list = list(equal) equal_x = equal_list[0]
left, top, right, bottom, screen_height, screen_width) move_mouse(mx, my) else: mx, my = pyautogui.position() if mouse_box is None: bxmin, bymin, bxmax, bymax = get_mouse_box(mx, my, box_side=50) mouse_box = [bxmin, bymin, bxmax, bymax] else: if is_in_mousebox(mx, my, mouse_box): mouse_in_box_frames += 1 else: bxmin, bymin, bxmax, bymax = get_mouse_box(mx, my, box_side=50) mouse_box = [bxmin, bymin, bxmax, bymax] if mouse_in_box_frames >= 4: pyautogui.click(pyautogui.position()) mouse_in_box_frames = 0 cv2.imshow("Captured Image + Detection", prep_show_img(img, left, top, right, bottom)) captured_key = cv2.waitKey(10) if (captured_key & 0xff) == ord("q"): cv2.destroyAllWindows() break elif (captured_key & 0xff) == ord(" "): paused = not paused cap.release()
def clickInGame(imageCoords): pyautogui.moveTo(imageCoords, duration=2) pyautogui.click(imageCoords, duration=.2) pyautogui.mouseUp(imageCoords, duration=.1)
def kritaClearWritingArea(self): controller.click(1360, 860) controller.hotkey('ctrl', 'a') controller.hotkey('delete')
def makeShape(): sleep(1) # 최소 경계 도형 선택 toolBox1 = cv2.imread(r'mac\IMAGE\toolbox.png') toolBox2 = cv2.imread(r'mac\IMAGE\toolbox2.png') toolBox3 = cv2.imread(r'mac\IMAGE\toolbox3.png') toolboxA = pyautogui.locateCenterOnScreen(toolBox1) toolboxB = pyautogui.locateCenterOnScreen(toolBox2) toolboxC = pyautogui.locateCenterOnScreen(toolBox3) if toolboxA != None: # print(toolboxA) pyautogui.moveTo(toolboxA) pyautogui.click() sleep(1) elif toolboxB != None: # print(toolboxB) pyautogui.moveTo(toolboxB) pyautogui.click() sleep(1) else: # print(toolboxC) pyautogui.moveTo(toolboxC) pyautogui.click() sleep(1) pyautogui.doubleClick() sleep(2) #도형유형 선택 shapeType = cv2.imread(r'mac\IMAGE\stype.png') shapeTypeA = pyautogui.locateCenterOnScreen(shapeType) pyautogui.moveTo(shapeTypeA) pyautogui.moveRel(0, 20) pyautogui.click() sleep(0.2) pyautogui.moveRel(0, 60, 0.1) pyautogui.click() sleep(0.5) #### 실행하기 인식이 안됌? 이상함 그래서 걍 상대값 찾아서 넣음 ??? 이거 진짜 왜 안돌아가지?? #### practice = cv2.imread(r'mac\IMAGE\prac.png') #### practiceA= pyautogui.locateCenterOnScreen(practice) #### pyautogui.moveTo(practiceA) # 실행하기 상대값 좌표 (창크기가 바뀌면 절대 안됌 사이즈를 알아서 맞춰주어야함) pyautogui.moveRel(600, 355) pyautogui.click() sleep(2) pyautogui.hotkey('esc')
import pyautogui as pag import time if __name__ == '__main__': #메모장 실행 pag.moveTo(190, 1030, 2) pag.click() pag.press("hangul") pag.typewrite("apah") pag.press("hangul") pag.moveTo(260, 310, 2) pag.click(interval=0.5) pag.click() pag.typewrite("hello world") # 두번 내리자 pag.press("enter") pag.press("enter") # 반갑구나 세상아 치자 pag.press("hangul") pag.typewrite("qksrkqrnsk tptkddk") pag.press("hangul") # 저장하자 pag.hotkey('ctrl', 's') time.sleep(1) # pag.moveTo(30, 50, 2) # pag.click() # pag.moveTo(90, 150, 2) # pag.click() # 파일이름 : 파이썬월드 pag.press("hangul") pag.typewrite("C:\\Users\\김선옥\\OneDrive\\바탕 화면\\")
@author: hawk """ import pyautogui # 获取当前屏幕分辨率 screenWidth, screenHeight = pyautogui.size() # 获取当前鼠标位置 currentMouseX, currentMouseY = pyautogui.position() # 2秒钟鼠标移动坐标为100,100位置 绝对移动 pyautogui.moveTo(200, 180,2) # 鼠标左击一次 pyautogui.click() import cv2 import time import requests import base64 def recognize(): request_url = "https://aip.baidubce.com/rest/2.0/image-classify/v1/gesture" # 二进制方式打开图片文件 f = open('/home/hawk/Desktop/ML/Project/image/image2.jpg', 'rb') img = base64.b64encode(f.read())
import pyautogui pyautogui.click(10, 5, button='left') """ **You can also perform a click by calling pyautogui.mouseDown(), which only pushes the mouse button down, and pyautogui.mouseUp(), which only releases the button. These functions have the same arguments as click(), and in fact, the click() function is just a convenient wrapper around these two function calls. **As a further convenience, the pyautogui.doubleClick() function will perform two clicks with the left mouse button, while the pyautogui.rightClick() and pyautogui.middleClick() functions will perform a click with the right and middle mouse buttons, respectively. """
if k == 'yes': continue elif k == 'no': if not len(nameData) > 0: print('You must provide at least one recipient.') continue break print('Ensure that the messenger window is fullscreen, loaded and active!') input('Press Enter when you are ready to begin.') for i in range(len(nameData)): print('>>> 5-SECOND PAUSE TO LET USER PRESS CTRL-C <<<') time.sleep(5) print('Sending message to %s...' % (nameData[i])) #Locate search box, type name, select pyautogui.click(searchCoords[0], searchCoords[1]) time.sleep(1) pyautogui.write(nameData[i], 0.25) time.sleep(1) pyautogui.write(['down', 'enter'], 0.5) time.sleep(1) #Locate the message box, type the message, send pyautogui.click(messageCoords[0], messageCoords[1]) time.sleep(1) pyautogui.write(messageData, 0.25) time.sleep(1) pyautogui.press('enter') time.sleep(5) print('Program Complete. Notifications sent.')
def start(self): pyautogui.moveTo(1130,16) pyautogui.click()
import pyautogui import time time.sleep(5) print(pyautogui.position()) pyautogui.moveTo(271,555) pyautogui.rightClick() time.sleep(5) print(pyautogui.position()) pyautogui.click(298,748)
def bounce(): # print('jump') # pyautogui.moveTo(1693, 393) pyautogui.click(1696, 963)
def GameClick(x1, y1, clicks, delay): for k in range(clicks): pyautogui.moveTo(x1, y1) pyautogui.click() time.sleep(delay)
import pyautogui as gui import time import random as rd i=10 #time.sleep(5) #print(gui.position()) #exit() while(i>0): #time.sleep(5) time.sleep(rd.choice(range(5,30))) gui.click(90,10) time.sleep(8) Pt = gui.locateCenterOnScreen('Name.png') gui.click(Pt.x, Pt.y-20) i=i-1 time.sleep(3) gui.hotkey('ctrl','w') exit()
import pyautogui import time print(pyautogui.position()) # 404, 674 # pyautogui.moveTo(1645,433) # pyautogui.click(clicks=2,interval=2) #클릭 2번, 2초텀 # pyautogui.moveRel(0,300) # pyautogui.doubleClick() # time.sleep(1) # pyautogui.typewrite("hello") # pyautogui.typewrite(['enter']) # 키를 누르는것 'abc'는 안됨 # pyautogui.typewrite("hohoho") # pyautogui.typewrite(['a','b','c','enter']) # print(pyautogui.position()) pyautogui.screenshot('1.png', region=(262, 556, 30, 30)) num1 = pyautogui.locateCenterOnScreen('1.png') pyautogui.click(num1)
import webbrowser import pyautogui import time webbrowser.open('http://127.0.0.1:5000', new=1, autoraise=True) time.sleep(.5) pyautogui.click(x=418, y=537) time.sleep(.1) pyautogui.click(x=949, y=793)
pyautogui.hotkey('ctrl', 't') # abrir o drive link = 'https://drive.google.com/drive/folders/1wRTFw0sUVBjRr4hW5U9LF7DjLixRyxym' pyperclip.copy( link ) # melhor abordagem que copiar a string dentro do método. digitar a string aos poucos pode induzir a erros por autocorretor, por exemplo pyautogui.hotkey('ctrl', 'v') pyautogui.press('enter') time.sleep(7) # instrui o sistema a aguardar até a operação completar #baixar a base de dados # time.sleep(5) # pyautogui.position() # capturar posição do mouse pyautogui.rightClick(1345, 495) pyautogui.click(1395, 923) time.sleep(10) # acessar o banco de dados pelo pandas df = pd.read_excel(r'C:\Users\gusta\Downloads\Vendas - Dez.xlsx') display(df) # calculando faturamento e quantidade de produtos faturamento = df['Valor Final'].sum() qtde = df['Quantidade'].sum() # acessar o gmail pyautogui.hotkey('ctrl', 't') pyautogui.write('mail.google.com') pyautogui.press('enter') time.sleep(5)
import pyautogui import pyperclip #INICIAR SESION pyautogui.click( ) #click para poner como ventana principal a la web (estaba en terminal) for i in range(0, 12): #tab hasta llegar a login pyautogui.press('tab') pyperclip.copy("userblopez") pyautogui.hotkey("command", "v") pyautogui.press('tab') pyperclip.copy("passblopez") pyautogui.hotkey("command", "v") pyautogui.press('tab') pyautogui.press('enter') #logear
def click_mouse(x, y, left=True, speed=1.0): '''moves to and clicks a point''' move_mouse(x, y, speed=speed) pyautogui.click(button='left' if left else 'right')
def newSceneKrita(self): x, y = controller.position() controller.click(1350, 580) controller.moveTo(x, y)
import pyautogui from PIL import ImageGrab y = 900 while True: if ImageGrab.grab().getpixel((555, y))[0] == 1 : pyautogui.click(555, y) if ImageGrab.grab().getpixel((620, y))[0] == 1 : pyautogui.click(620, y) if ImageGrab.grab().getpixel((690, y))[0] == 1 : pyautogui.click(690, y) if ImageGrab.grab().getpixel((750, y))[0] == 1 : pyautogui.click(750, y)
int(LoCoor[each].split(',')[1][0:-1:]) ]) except: #if LoCoor[each] == '': #tempL.append() #else: pass for _ in range(recursion): n = 0 for each in range(len(tempL)): if n != len(clicksIndices) - 1: if clicksIndices[n][0] == each: pyautogui.move(tempL[each][0], tempL[each][1], 0.05) if clicksIndices[n][1] == 1: pyautogui.click(tempL[each][0], tempL[each][1], button='right', clicks=1) elif clicksIndices[n][1] == 0: pyautogui.click(tempL[each][0], tempL[each][1], button='left', clicks=1) n += 1 else: pyautogui.move(tempL[each][0], tempL[each][1], 0.05) else: pyautogui.move(tempL[each][0], tempL[each][1], 0.05) elif FI == '2': run = False #DataPaper = open("", "r", encoding = "utf8")
import pyautogui as pg import time pg.click(4, 2, 5) pg.click(1107, 33, 1) pg.hotkey('winleft', 'ctrl', 'd') pg.hotkey('winleft') pg.typewrite('chrom\n', 0.5) pg.hotkey('winleft', 'up') pg.typewrite('www.glossier.com\n', 0.5) pg.moveTo(178, 159, 3) time.sleep(3) pg.click(347, 430)
def test_animatorStepIncrement(cartavisInstance, cleanSlate): """ Test that the Animator can be set to different step increment values. """ i = cartavisInstance.getImageViews() a = cartavisInstance.getAnimatorViews() # Load an image i[0].loadFile(os.getcwd() + '/data/N15693D.fits') # Open animator settings _openAnimatorSettings() # Find the step increment spin box and change the step increment to 2 stepIncrement = ImageUtil.locateCenterOnScreen('test_images/stepIncrement.png') pyautogui.click(x=stepIncrement[0]+40, y=stepIncrement[1]) pyautogui.press('delete') pyautogui.typewrite('2') pyautougi.press('return') # Go to the next channel value a[0].setChannel(0) _getNextValue() assert a[0].getChannelIndex() == 2 # Close animator settings _openAnimatorSettings()