def main(): if width != 1920 and height !=1080: print "Invalid resolution. Only 1080p currently supported. " return killerSlash = (1354,986) red = (240,0,0) gray = (93,90,85) black = (0,0,0) readpos = (1770,1000) slashPos = [(1383,971)] ourSlash = slashPos[0] while True: if pyautogui.pixelMatchesColor(ourSlash[0], ourSlash[1], gray): pyautogui.click(x=readpos[0], y=readpos[1]) elif pyautogui.pixelMatchesColor(ourSlash[0], ourSlash[1], black, tolerance=20): while pyautogui.pixelMatchesColor(ourSlash[0], ourSlash[1], black, tolerance=20): time.sleep(1) if pyautogui.pixelMatchesColor(killerSlash[0], killerSlash[1], red) or pyautogui.pixelMatchesColor(killerSlash[0], killerSlash[1], gray): return if pyautogui.pixelMatchesColor(killerSlash[0], killerSlash[1], black): continue time.sleep(1)
def open_file(self, file_name): pyautogui.click(585, 150) pyautogui.press(['alt', 'f', 'o']) start = time.time() while not pyautogui.pixelMatchesColor(278, 90, (255, 255, 255)): time.sleep(1) if int(time.time() - start) > 20: ignore_file = file_name open_status = False break else: ignore_file = None open_status = True time.sleep(2) pyautogui.click(444, 123) time.sleep(1) pyautogui.press('delete') open_path = 'C:\\Users\\hardip thummar\\Desktop\\New folder (2)' pyautogui.typewrite(open_path) pyautogui.press('enter') pyautogui.click(472, 492) pyautogui.typewrite(file_name) pyautogui.press('enter') return open_status, ignore_file
def download_csv(name,url, *args,**kwargs): webbrowser.open(url) match1=False while not match1: im=gui.screenshot() im.getpixel((973, 131)) match1=gui.pixelMatchesColor(973,131,(85,85,85)) match1=False gui.click(973,131) while not match1: gui.press('end') center_x,center_y,match=location("csv.png") match1=match match1=False gui.click(center_x,center_y) # center_x,center_y=location("option_btn.png") # gui.click(center_x,center_y) # center_x,center_y,match=location("submit.png") # gui.click(center_x,center_y) center_x,center_y,match=location("guardar.png") gui.typewrite(name) # center_x,center_y,match=location("txt.png") gui.press("enter") center_x,center_y,match=location("yes.png") gui.click(center_x,center_y)
def fishing(): max_runtime_sec = 60 * 60 * 24 while (max_runtime_sec > 0): time.sleep(1) max_runtime_sec = max_runtime_sec - 1 for color in target_colors: print("Color %s" % color) pos = pyautogui.pixelMatchesColor(100, 200, tuple(color)) # AutoPy # autopy.bitmap.capture_screen().save(os.path.join(os.getcwd(), screenshot_path)) # source = autopy.bitmap.Bitmap.open(screenshot_path) # result = autopy.bitmap.Bitmap.find_color() # print(result) # pos = source.find_bitmap(result) # if pos: # autopy.mouse.move(pos[0] / scale, pos[1] / scale) print("Found avator at: %s" % str(pos))
def _check_metal(self): metals = Metals() total_metal = 0 for x_offset in metals.x_offset_list: x, y = cordinates_scale((x_offset, metals.y_offset), constants.WINDOW_ATTRIBUTES) metal_x = x + self.region[0] metal_y = y + self.region[1] if not self.finished: if not pyautogui.pixelMatchesColor(metal_x, metal_y, Metals.color, tolerance=10): total_metal += 1 else: if not pyautogui.pixelMatchesColor(metal_x, metal_y, Metals.finished_color, tolerance=2): total_metal += 1 # print(metal_x, metal_y) self.metals = total_metal self.logger.debug(f'total metals: {total_metal}')
def in_port(): point = settings.SHIP_FILTER_BUTTON color = (148, 198, 199) result = pag.pixelMatchesColor(*point, color, tolerance=10) if result: check_battle_mode() return result
def episode_getfund(insur_code, fund, fund_number, ref): # ref may contain garrison episode id while True: if not pya.pixelMatchesColor(150, 630, (255, 0, 0)): print('Open the patient file.') input('Hit Enter when ready.') else: break # get mcn if insur_code == 'ga': mcn = '' elif insur_code == 'os' and fund != 'Overseas': fund_number = episode_get_fund_number() fund = episode_get_fund_name() mcn = ref = '' elif insur_code == 'os' and fund == 'Overseas': mcn = ref = '' elif insur_code in {'p', 'u', 'v'}: fund_number = '' mcn, ref = episode_get_mcn_and_ref() else: fund_number = episode_get_fund_number() mcn, ref = episode_get_mcn_and_ref() return (mcn, ref, fund, fund_number)
def Win_Finish_Others(Seat): if Seat == 1: return pixelMatchesColor(po[0] + 419, po[1] + 412, (249, 126, 8)) #Win-Finish-Others-seat-1 if Seat == 2: return pixelMatchesColor(po[0] + 164, po[1] + 411, (249, 127, 8)) #Win-Finish-Others-seat-2 if Seat == 3: return pixelMatchesColor(po[0] - 91, po[1] + 419, (248, 123, 9)) #Win-Finish-Others-seat-3 if Seat == 4: return pixelMatchesColor(po[0] - 121, po[1] + 112, (248, 124, 9)) #Win-Finish-Others-seat-4 if Seat == 5: return pixelMatchesColor(po[0] + 449, po[1] + 112, (248, 124, 9)) #Win-Finish-Others-seat-5
def click_end_date(): end_cal_end = (cal_end[0] + 10, cal_end[1] + 100) cal_box_x_offset = 137 cal_box_y_offset = 136 cal_box_00 = end_cal_end cal_box_10 = (end_cal_end[0] + cal_box_x_offset, end_cal_end[1]) cal_box_11 = (end_cal_end[0] + cal_box_x_offset, end_cal_end[1] + cal_box_y_offset) cal_box_01 = (end_cal_end[0], end_cal_end[1] + cal_box_y_offset) pyautogui.moveTo(cal_box_00, duration=0.25) pyautogui.moveTo(cal_box_10, duration=0.25) pyautogui.moveTo(cal_box_11, duration=0.25) pyautogui.moveTo(cal_box_01, duration=0.25) target_pixel_color = (66, 111, 217) pyautogui.moveTo(cal_box_00, duration=0.25) for y_offset in range(cal_box_y_offset, 0, -5): for x_offset in range(cal_box_x_offset, 0, -10): pyautogui.moveTo(cal_box_00[0] + x_offset, cal_box_00[1] + y_offset) if pyautogui.pixelMatchesColor(cal_box_00[0] + x_offset, cal_box_00[1] + y_offset, (target_pixel_color)): print("Match found at") print(cal_box_00[0] + x_offset, cal_box_00[1] + y_offset) pyautogui.click(button='left') return
def click_start_date(): start_cal_start = (cal_start[0] + 10, cal_start[1] + 100) cal_box_x_offset = 137 cal_box_y_offset = 136 cal_box_00 = start_cal_start cal_box_10 = (start_cal_start[0] + cal_box_x_offset, start_cal_start[1]) cal_box_11 = (start_cal_start[0] + cal_box_x_offset, start_cal_start[1] + cal_box_y_offset) cal_box_01 = (start_cal_start[0], start_cal_start[1] + cal_box_y_offset) pyautogui.moveTo(cal_box_00, duration=0.25) pyautogui.moveTo(cal_box_10, duration=0.25) pyautogui.moveTo(cal_box_11, duration=0.25) pyautogui.moveTo(cal_box_01, duration=0.25) target_pixel_color = (66, 111, 217) pyautogui.moveTo(cal_box_00, duration=0.25) for y_offset in range(0, cal_box_y_offset, 5): for x_offset in range(0, cal_box_x_offset, 10): pyautogui.moveTo(cal_box_00[0] + x_offset, cal_box_00[1] + y_offset) if pyautogui.pixelMatchesColor(cal_box_00[0] + x_offset, cal_box_00[1] + y_offset, (target_pixel_color)): print("Match found at") print(cal_box_00[0] + x_offset, cal_box_00[1] + y_offset) pyautogui.click(button='left') return
def getmsg(): global x, y try: position = pt.locateOnScreen("paperclip.PNG", confidence=.6) x = position[0] y = position[1] ##pt.moveTo(x,y,duration=.5) x += 100 y -= 50 pt.moveTo(x, y, duration=.5) posXY = pt.position() try: if pt.pixelMatchesColor(int(posXY[0]), int(posXY[1]), (255, 255, 255), tolerance=10): pt.moveRel(-10, 0) pt.tripleClick() pt.moveRel(60, 80) pt.click() pt.typewrite(msg_to_send_pray, interval=.5) pt.typewrite("\n") sleep(0.5) pt.press('enter') else: print("waiting for new msg") except (Exception): print("color match failed") except (Exception): print("paperclip not found") sleep(3)
def wait_for_menu(): #(255, 255, 255) startx = test["size"]["x"] * button_offsets["PLAY"][0] starty = test["size"]["y"] * button_offsets["PLAY"][1] clickx = test["location"]["x"] + startx clicky = test["location"]["y"] + starty ctr = 0 while True: if pyautogui.pixelMatchesColor(int(clickx), int(clicky), (255, 255, 255)): print("\nFound menu!") return idx = ctr % 3 if idx == 0: print(f"Menu not visible, waiting 5 seconds. ", end="\r", flush=True) if idx == 1: print(f"Menu not visible, waiting 5 seconds.. ", end="\r", flush=True) if idx == 2: print(f"Menu not visible, waiting 5 seconds...", end="\r", flush=True) ctr = ctr + 1 time.sleep(5)
def wait_for_next_refresh(self): while pyautogui.pixelMatchesColor(self.waiting_color_cords[0], self.waiting_color_cords[1], self.waiting_color): accept_invite() MINUTE_CORDS = add_pos_with_offset( JIEJIE_OCR_LOCATION.PERSONAL_WAITING_MINUTE, constants.WINDOW_ATTRIBUTES) SECOND_CORDS = add_pos_with_offset( JIEJIE_OCR_LOCATION.PERSONAL_WAITING_SECOND, constants.WINDOW_ATTRIBUTES) minute_img = Image.fromarray(grab_screen(MINUTE_CORDS)) minute_str = pytesseract.image_to_string(minute_img, lang='eng', config='-psm 6').replace( 'O', '0') second_img = Image.fromarray(grab_screen(SECOND_CORDS)) second_str = pytesseract.image_to_string(second_img, lang='eng', config='-psm 6').replace( 'O', '0') try: waiting_second = int(minute_str) * 60 + int(second_str) logging.info(f'waiting time: {minute_str}:{second_str}...') return time.sleep(waiting_second) except Exception as e: logging.debug( f'minute_str: {minute_str}; second_str: {second_str}') time.sleep(1)
def Cards(Seat): if Seat == 1: return pixelMatchesColor(po[0] + 330, po[1] + 331, (154, 7, 13)) #Cards_seat_1 if Seat == 2: return pixelMatchesColor(po[0] + 74, po[1] + 332, (154, 7, 13)) #Cards_seat_2 if Seat == 3: return pixelMatchesColor(po[0] - 181, po[1] + 331, (154, 7, 13)) #Cards_seat_3 if Seat == 4: return pixelMatchesColor(po[0] - 140, po[1] + 212, (154, 7, 13)) #Cards_seat_4 if Seat == 5: return pixelMatchesColor(po[0] + 359, po[1] + 212, (154, 7, 13)) #Cards_seat_5
def attack(): print("攻击目标") pyautogui.press('j') if pyautogui.pixelMatchesColor(561, 47, (88, 17, 20)) : pyautogui.press('f6') else: pyautogui.press('f7')
def pixel(): """ 要获取截屏某个位置的RGB像素值,可以用Image对象的getpixel()方法: :return: """ im = pyautogui.screenshot() im.getpixel((100, 200)) # 也可以用PyAutoGUI的pixel()函数,是之前调用的包装: pyautogui.pixel(100, 200) # 如果你只是要检验一下指定位置的像素值,可以用pixelMatchesColor()函数, # 把X、Y和RGB元组值穿入即可: pyautogui.pixelMatchesColor(100, 200, (255, 255, 255)) # tolerance参数可以指定红、绿、蓝3种颜色误差范围: pyautogui.pixelMatchesColor(100, 200, (255, 255, 245), tolerance=10)
def Win_Finish_Me(Seat): if Seat == 1: return pixelMatchesColor(po[0] + 442, po[1] + 415, (248, 125, 9)) #Win-Finish-Me-seat-1 if Seat == 2: return pixelMatchesColor(po[0] + 187, po[1] + 422, (248, 123, 10)) #Win-Finish-Me-seat-2 if Seat == 3: return pixelMatchesColor(po[0] - 68, po[1] + 415, (248, 125, 9)) #Win-Finish-Me-seat-3 if Seat == 4: return pixelMatchesColor(po[0] - 98, po[1] + 95, (250, 130, 6)) #Win-Finish-Me-seat-4 if Seat == 5: return pixelMatchesColor(po[0] + 472, po[1] + 95, (250, 130, 6)) #Win-Finish-Me-seat-5
def check_pixel_color(rgb, position=None, tolerance=10): if position is None: x, y = pyautogui.position() else: x, y = position return pyautogui.pixelMatchesColor(x, y, rgb, tolerance=tolerance)
def check_for_new_messages(): pt.moveTo(x + 50, y - 30, duration=.5) while True: #Continuosly checks for green dot and new messages try: position = pt.locateOnScreen("green_circle.png", confidence=.7) if position is not None: pt.moveTo(position) pt.moveRel(-10, 0) pt.click() sleep(.5) except (Exception): print("No new other users with new messages located") if pt.pixelMatchesColor(int(x + 50), int(y - 35), (255, 255, 255), tolerance=10): print("is_white") processed_message = process_response(get_message()) post_response(processed_message) else: print("No new messages yet:...") sleep(5)
def open_files(self, file): pyautogui.click(650, 250) pyautogui.press(['alt', 's', 'o']) # code to open dialog box start = time.time() while not (pyautogui.pixelMatchesColor( 1027, 473, (195, 203, 214))): # pixels for open dialog box time.sleep(1) if int(time.time() - start) > 20: status_ok = False ignore_file = file break else: status_ok = True ignore_file = None time.sleep(1) pyautogui.click(411, 46, button='left') time.sleep(0.5) pyautogui.click(426, 80, button='left') pyautogui.click(517, 720, button='left') pyautogui.press('backspace', presses=30) time.sleep(1) file_name, extension = os.path.splitext(file) split_name = file_name.split('(')[0] time.sleep(1) pyautogui.typewrite(split_name) time.sleep(3) pyautogui.press('enter') return status_ok, ignore_file
def clearAppScreen(): # Clear any open menus pyautogui.hotkey('alt', 'w', 'l') pyautogui.press('esc') # Check for empty screen background while pyautogui.pixelMatchesColor(1500, 200, (194, 196, 197)) == False: print('#Check for empty screen: RGB not matched')
def sight_loop(): print("Fishing...") posX, posY = pyautogui.position() posXString = str(posX) posYString = str(posY) print("Mouse Position x: " + posXString + " y: " + posYString) try: rgbValues = pyautogui.screenshot().getpixel((954, 415)) print("the three rgb colours are " + str(rgbValues[0]) + " " + str(rgbValues[1]) + " " + str(rgbValues[2])) if (pyautogui.pixelMatchesColor(955, 437, (255, 255, 250)) == True): print("Statement1") elif (rgbValues[0] >= 200 or rgbValues[1] >= 200 or rgbValues[2] >= 200): print("we got a fish!") time.sleep(0.5) pyautogui.typewrite('3') time.sleep(8) pyautogui.typewrite('6') # mooch time.sleep(0.5) #pyautogui.typewrite('0') # release time.sleep(0.5) pyautogui.typewrite('2') # cast pass else: print("Fish not biting..") except: print("Mouse not on correct screen..")
def is_gun_ready(self): result = pag.pixelMatchesColor(*settings.GUN_READY, (30, 200, 120), tolerance=30) if not result: print('gun is not ready.') return result
def checker(): count = 0 while count < 1: for ypos in ypositions: pag.moveTo(xpos, ypos) # move mouse for fun # check if pixel area is blank or has text if pag.pixelMatchesColor( xpos, ypos, (249, 249, 249) ): # bg color of icloud-mail is #f9f9f9 or rgb(249, 249, 249) print(f'testing... pixel is white... empty ?') count = 1 # set count to 1, will goto next search_term if loop ends here else: print('pixel not white, delete messages and repeat \n') pag.click(first_msg_area) # click on first message area time.sleep(0.5) pag.hotkey('ctrl', 'a') # type ctrl+a to select all messages time.sleep(2) pag.click(trash_btn) # click the trash can button time.sleep(10) count = 0 # set count to 0, the while loop will continue break # break out of current loop
def on_land_check(): global leave_game_time global grounded_time if yn_debug == 1: print('There is '+str(leave_game_time)+' Seconds till the bot leaves the game!') if yn_debug == 1: print('Landed!') leave_game_time -= grounded_time sleep(3) leave_game_time -= 6 if yn_debug == 1: print('The time reduce amount is '+str(grounded_time)+' Seconds.') if yn_debug == 1: print('You now have to wait '+str(leave_game_time)+' Seconds till the bot leaves the game!') press('z') for i in range(1, 200): if yn_debug == 1: print('Check to see if you are in water #'+str(i)) if pixelMatchesColor(1207, 1036, (238, 241, 241), tolerance=30) is True and pixelMatchesColor(1227, 1041, (241, 243, 244), tolerance=30) is True:#player animation of standing and laying down if yn_debug == 1: print('You are in water.') for v in range(1, round(leave_game_time)) [::-1]: if pixelMatchesColor(1637, 960, (255, 255, 255)) is True and pixelMatchesColor(1765, 944, (255, 255, 255)) is True: check_if_dead() if pixelMatchesColor(172, 38, (255, 255, 255)) is True and pixelMatchesColor(172, 53, (255, 255, 255)) is True:#checks to see if you are in a parachute fallback_debug_self_fix() if yn_debug == 1: print('Time left before restart: '+str(i)+' ') keyDown('space') sleep(0.5) keyUp('space') sleep(0.5) end_game_restart() if yn_debug == 1: print('You are on gound.') for i in range(1, round(leave_game_time)) [::-1]: if pixelMatchesColor(1637, 960, (255, 255, 255)) is True and pixelMatchesColor(1765, 944, (255, 255, 255)) is True: check_if_dead() if pixelMatchesColor(172, 38, (255, 255, 255)) is True and pixelMatchesColor(172, 53, (255, 255, 255)) is True:#checks to see if you are in a parachute fallback_debug_self_fix() if yn_debug == 1: print('Time left before restart: '+str(i)+' ') sleep(1) end_game_restart() sleep(1) fallback_debug_self_fix()
def process_file(self, file_name): start = time.time() while not pyautogui.pixelMatchesColor(159, 51, (250, 250, 250)): time.sleep(1) if int(time.time() - start) > 20: ignore_file = file_name process_status = False break else: pyautogui.click(434, 181, button='right') time.sleep(1) pyautogui.press('r') pyautogui.press(['alt', 'f', 'a']) start = time.time() while not (pyautogui.pixelMatchesColor(75, 59, (250, 250, 250)) and pyautogui.pixelMatchesColor(829, 508, (33, 117, 200))): time.sleep(1) if int(time.time() - start) > 40: ignore_file = file_name process_status = False break else: time.sleep(2) pyautogui.click(730, 515) start = time.time() while not pyautogui.pixelMatchesColor(117, 86, (233, 31, 0)): time.sleep(1) if int(time.time() - start) > 20: ignore_file = file_name process_status = False break else: time.sleep(1) pyautogui.click(439, 122) pyautogui.press('delete') time.sleep(1) save_path = 'C:\\Users\\hardip thummar\\Desktop\\New folder (3)' pyautogui.typewrite(save_path) time.sleep(1) pyautogui.press('enter') pyautogui.click(552, 524) process_status = True ignore_file = None time.sleep(1) return process_status, ignore_file
def check_attack_dis(self): _range = self.check_range() if pyautogui.pixelMatchesColor(939, 970, (194, 39, 37), 3): if _range is RANGE.ROOR: return 'far' if _range == RANGE.R0005 or _range == RANGE.R0520: return 'near' return 'good'
def waitWindow(p_x, p_y, p_r, p_g, p_b): i = 1 while True: if pa.pixelMatchesColor(p_x, p_y, (p_r, p_g, p_b)) == True: # 수덕원 예약 아이콘 좌표 및 색상코드 break print('%s번째 시도중...' %(i)) i += 1 time.sleep(1)
def wait(pos, bgr, print_str='no str'): while True: if pyautogui.pixelMatchesColor(*pos, bgr): break print('wait for '+print_str) time.sleep(1) print('found '+print_str) time.sleep(1.5)
def check_have_fish(): # 检测是否上鱼 have_fish_color_check = pyautogui.pixelMatchesColor(1623, 866, (28, 67, 193), tolerance=30) if have_fish_color_check: return True return False
def managers(): p.moveTo(347, 520) p.click(347, 520) time.sleep(0.5) while True: if p.pixelMatchesColor(1048, 492, (151, 191, 212)): p.moveTo(1048, 492) p.click(1048, 492) p.moveTo(1256, 235) time.sleep(0.5) while p.pixelMatchesColor(930, 380, (176, 219, 126)): p.moveTo(930, 380) p.click(930, 380) else: p.moveTo(1256, 235) p.click(1256, 235) break
def daily_pinata(): print("Running Pinata.") moveToCity() if building_check('pinata'): print("Pinata found!") try: center = building_check('pinata') circlepress(center[0], center[1]) time.sleep(2) except: print("Pinata not found.") time.sleep(2) moveToCity() return listOfPinatas = pyautogui.locateAllOnScreen('images/pinata_center.jpg') listOfCenters = [] for centerofpinata in listOfPinatas: listOfCenters.append(pyautogui.center(centerofpinata)) random.shuffle(listOfCenters) for pinata in listOfCenters: print(f"original point is {pinata}") circlepress(pinata[0], pinata[1], radius=15) time.sleep(random.uniform(.5, 1.2)) if pyautogui.pixelMatchesColor( 866, 920, (116, 195, 41), tolerance=10 ): #if pixel at bottom is green, ie you've bust print("Bummer. You drew a bomb.") time.sleep(.25) moveToCity() break if pyautogui.pixelMatchesColor(1083, 968, (2, 59, 66), tolerance=10): print("Fortune Teller Time!") time.sleep(random.uniform(5, 7)) boxpress(779, 851, 907, 876) #press try time.sleep(random.uniform(4, 6)) boxpress(582, 816, 1088, 921) #randomly presses a card time.sleep(random.uniform(2, 4)) boxpress(976, 954, 1091, 979) #presses fold time.sleep(random.uniform(2, 4)) boxpress(776, 543, 904, 574) #presses confirm time.sleep(random.uniform(3, 5))
def episode_open(message): while True: if not pya.pixelMatchesColor(150, 630, (255, 0, 0)): print('Open the patient file.') input('Hit Enter when ready.') else: break pya.moveTo(150, 50) pya.click() pya.press('f8') while not pya.pixelMatchesColor(534, 330, (102, 203, 234), tolerance=10): time.sleep(0.3) pya.press('n') while not pya.pixelMatchesColor(820, 130, (195, 90, 80), tolerance=10): time.sleep(0.3) pya.typewrite(['down'] * 11, interval=0.1) pya.press('enter') pya.hotkey('alt', 'f') time.sleep(2) pic = 'd:\\John TILLET\\source\\active\\billing\\aileen.png' while pya.locateOnScreen(pic, region=(0, 45, 150, 40)) is not None: time.sleep(1) if pya.pixelMatchesColor(520, 380, (25, 121, 202), tolerance=10): time.sleep(0.3) pya.press('enter') pya.press('c') pya.hotkey('alt', 'f4') time.sleep(1) pya.press('f8') time.sleep(1) pya.typewrite(['enter'] * 3, interval=1.0) message += ' New episode made.' time.sleep(3) return message
def runner(*args): try: message = '' anaesthetist = an.get() endoscopist = end.get() nurse = nur.get() asa = asc.get() if asa == 'No sedation': message += 'No sedation.' asa = gnc.ASA_DIC[asa] upper = up.get() if upper == 'Cancelled': message += 'Upper cancelled.' if upper == 'Pe with varix banding': message += 'Bill varix bander.' varix_lot = pya.prompt(text='Enter the varix bander lot number.', title='Varix', default='') else: varix_lot = '' if upper == 'HALO': halo = pya.prompt(text='Type either "90" or "ultra".', title='Halo', default='90') message += halo + '.' upper = gnc.UPPER_DIC[upper] colon = co.get() if colon == 'Cancelled': message += 'Colon Cancelled.' colon = gnc.COLON_DIC[colon] banding = ba.get() if banding == 'Banding of haemorrhoids': message += ' Banding haemorrhoids.' if endoscopist == 'Dr A Wettstein': message += ' Bill bilateral pudendal blocks.' if banding == 'Anal Dilatation': message += ' Anal dilatation.' if endoscopist == 'Dr A Wettstein': message += ' Bill bilateral pudendal blocks.' banding = gnc.BANDING_DIC[banding] clips = cl.get() clips = int(clips) if clips != 0: message += 'clips * {}.'.format(clips) consult = con.get() consult = gnc.CONSULT_DIC[consult] formal_message = mes.get() if formal_message: message += formal_message + '.' op_time = ot.get() op_time = int(op_time) (in_theatre, out_theatre) = in_and_out_calculater(op_time) if upper is None and colon is None: pya.alert(text='You must enter either an upper or lower procedure!', title='', button='OK') raise BillingException if banding is not None and colon is None: pya.alert(text='Must enter a lower procedure with the anal procedure!', title='', button='OK') raise BillingException if '' in (anaesthetist, endoscopist, nurse): pya.alert(text='Missing data!', title='', button='OK') raise BillingException pya.click(50, 450) while True: if not pya.pixelMatchesColor(150, 630, (255, 0, 0)): pya.alert(text='Patient file not open??') raise BillingException else: break mrn, name = front_scrape() shelver(mrn, in_theatre, out_theatre, anaesthetist, endoscopist, asa, upper, colon, banding, nurse, clips, varix_lot, message) # web page with jinja2 message = message_parse(message) # break message into lines today_path = episode_to_csv( out_theatre, endoscopist, anaesthetist, name,consult, upper, colon, message, in_theatre, nurse, asa, banding, varix_lot, mrn) make_web_secretary(today_path) make_long_web_secretary(today_path) to_watched() time.sleep(2) close_out(anaesthetist) except BillingException: return asc.set('1') up.set('None') co.set('None') ba.set('None') cl.set('0') con.set('None') mes.set('') ot.set('20')
#! coding: utf-8 """ On Linux computers, the scrot program needs to be installed to use the screenshot functions in PyAutoGUI. In a Terminal window, run sudo apt-get install scrot to install this program.""" import pyautogui im = pyautogui.screenshot() im.getpixel((200, 250)) # coord (x,y) => (130, 135, 144) pyautogui.pixelMatchesColor(200, 250, (130, 135, 144)) #check RGB value => True
def runner(*args): try: insur_code, fund, ref, fund_number, message = '', '', '','', '' anaesthetist = an.get() endoscopist = end.get() nurse = nur.get() asa = asc.get() if asa == 'No Sedation': message += 'No sedation.' asa = gnc.ASA_DIC[asa] upper = up.get() if upper == 'Cancelled': message += 'Upper cancelled.' if upper == 'Pe with varix banding': message += 'Bill varix bander.' varix_lot = pya.prompt(text='Enter the varix bander lot number.', title='Varix', default='') else: varix_lot = '' if upper == 'HALO': halo = pya.prompt(text='Type either "90" or "ultra".', title='Halo', default='90') message += halo + '.' upper = gnc.UPPER_DIC[upper] colon = co.get() if colon == 'Cancelled': message += 'Colon Cancelled.' colon = gnc.COLON_DIC[colon] banding = ba.get() if banding == 'Banding of haemorrhoids': message += ' Banding haemorrhoids.' if endoscopist == 'Dr A Wettstein': message += ' Bill bilateral pudendal blocks.' if banding == 'Anal Dilatation': message += ' Anal dilatation.' if endoscopist == 'Dr A Wettstein': message += ' Bill bilateral pudendal blocks.' banding = gnc.BANDING_DIC[banding] clips = cl.get() clips = int(clips) if clips != 0: message += 'clips * {}.'.format(clips) consult = con.get() consult = gnc.CONSULT_DIC[consult] formal_message = mes.get() if formal_message: message += formal_message + '.' op_time = ot.get() op_time = int(op_time) fund = fu.get() if fund == '': pya.alert(text='No fund!') raise BillingException insur_code = gnc.FUND_TO_CODE.get(fund, 'ahsa') if insur_code == 'ga': ref = pya.prompt(text='Enter Episode Id', title='Ep Id', default=None) fund_number = pya.prompt(text='Enter Approval Number', title='Approval Number', default=None) if insur_code == 'os': paying = pya.confirm(text='Paying today?', title='OS', buttons=['Yes', 'No']) if paying == 'Yes': fund = 'Overseas' else: fund = pya.prompt(text='Enter Fund Name', title='Fund', default='Overseas') (in_theatre, out_theatre) = in_and_out_calculater(op_time) if upper is None and colon is None: pya.alert(text='You must enter either an upper or lower procedure!', title='', button='OK') raise BillingException if banding is not None and colon is None: pya.alert(text='Must enter a lower procedure with the anal procedure!', title='', button='OK') raise BillingException if '' in (anaesthetist, endoscopist, nurse): pya.alert(text='Missing data!', title='', button='OK') raise BillingException pya.click(50, 450) while True: if not pya.pixelMatchesColor(150, 630, (255, 0, 0)): # print('Open the patient file.') # input('Hit Enter when ready.') # pya.click(50, 450) pya.alert(text='Patient file not open??') raise BillingException else: break mrn, name = front_scrape() address, dob = address_scrape() # scrape fund details if billing anaesthetist if asa is not None: (mcn, ref, fund, fund_number) = episode_getfund( insur_code, fund, fund_number, ref) else: mcn = ref = fund = fund_number = '' shelver(mrn, in_theatre, out_theatre, anaesthetist, endoscopist, asa, upper, colon, banding, nurse, clips, varix_lot, message) # anaesthetic billing if asa is not None: anaesthetic_tuple, message = bill_process( dob, upper, colon, asa, mcn, insur_code, op_time, name, address, ref, fund, fund_number, endoscopist, anaesthetist, message) to_anaesthetic_csv(anaesthetic_tuple, anaesthetist) if fund == 'Overseas': message = print_receipt( anaesthetist, anaesthetic_tuple, message) # web page with jinja2 message = message_parse(message) # break message into lines today_path = episode_to_csv( out_theatre, endoscopist, anaesthetist, name,consult, upper, colon, message, in_theatre, nurse, asa, banding, varix_lot, mrn) make_web_secretary(today_path) make_long_web_secretary(today_path) to_watched() time.sleep(2) render_anaesthetic_report(anaesthetist) close_out(anaesthetist) except BillingException: return asc.set('1') up.set('None') co.set('None') ba.set('None') cl.set('0') con.set('None') mes.set('') ot.set('20') fu.set('')
'robocop': 1, 'comments': 'Please take the puppets out of the break room.'}, {'name': 'Alex Murphy', 'fear': 'ED-209', 'source': 'money', 'robocop': 5, 'comments': 'Protect the innocent. Serve the public trust. Uphold the law.'}, ] pyautogui.PAUSE = 0.5 for person in form_data: # ユーザーがスクリプトを中断する機会を与える print('>>> 5秒間一時停止中。中断するにはCtrl-Cを押してください。<<<') time.sleep(5) # ❶ # フォームページが読み込まれるのを待つ while not pyautogui.pixelMatchesColor(submit_button[0], submit_button[1], submit_button_color): # ❷ time.sleep(0.5) print('{}の情報を入力中...'.format(person['name'])) # ❶ pyautogui.click(name_field[0], name_field[1]) # ❷ # Name欄を入力する pyautogui.typewrite(person['name'] + '\t') # ❸ # Greatest Fear(s)欄を入力する pyautogui.typewrite(person['fear'] + '\t') # ❹ # Source of Wizard Powers欄を選択する if person['source'] == 'wand': # ❶ pyautogui.typewrite(['down', '\t']) # ❷ elif person['source'] == 'amulet':
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"]; pyautogui.click(otherLink[0][0], otherLink[0][1]);
# Print the prettified race number. logging.info('\n\n' + ' RACE {} '.center(70, '=').format(str(race + 1)) + \ '\n') # Navigate through the main menu. # =============================== # Check whether the main page window is opened by locating the # green Start button. main_page_found = False x, y = START_BUTTON_COORDS color = START_BUTTON_COLOR while not main_page_found: if pyautogui.pixelMatchesColor(x, y, color): main_page_found = True logging.info('I am on the main page.') else: logging.info('Could not find the green Start button. Where am I?') time.sleep(1) # Check whether the user is logged in. If not, the custom race # cannot be created. pyautogui.moveTo(500, 600) # move mouse to some position in the # center so that it does not hover # over login button as in that case # it changes it's color to a darker one. x, y = LOGIN_BUTTON_COORDS color = LOGIN_BUTTON_COLOR # that is original Login button's color
"fear": "ED-209", "source": "money", "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 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 Name field pyautogui.typewrite(person["name"] + "\t") # Fill out Greatest Fear(s) field pyautogui.typewrite(person["fear"] + "\t") # Fill out Source of Wizard Powers field if person["source"] == "wand": pyautogui.typewrite(["down", "\t"]) elif person["source"] == "amulet":
formData = [{'name': 'Alice', 'fear': 'eavesdroppers', 'source': 'wand', 'robocop': 4, 'comments': 'Tell Bob I said hi.'}, {'name': 'Bob', 'fear': 'bees', 'source': 'amulet', 'robocop': 4, 'comments': 'n/a'}, {'name': 'Carol', 'fear': 'puppets', 'source': 'crystal ball', 'robocop': 1, 'comments': 'Please take out the puppets out of the break room.'}, {'name': 'Alex Murphy', 'fear': 'ED-209', 'source': 'money', 'robocop': 5, 'comments': 'Protect the innocent. Serve the public trust. Uphold the law.'}, ] pyautogui.PAUSE = 0.5 pyautogui.FAILSAFE = True 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 form page has loaded. while not pyautogui.pixelMatchesColor(formPageX, formPageY, formPageColor): time.sleep(0.5) print('Entering %s info...' % (person['name'])) pyautogui.click(nameFieldX, nameFieldY) # Fill out Name field pyautogui.typewrite(person['name'] + '\t') # Fill out Greatest Fear(s) field pyautogui.typewrite(person['fear'] + '\t') # Fill out Source of Wizard Powers field if person['source'] == 'wand': pyautogui.typewrite('\t') elif person['source'] == 'amulet':
pg.moveTo(1166,50,duration=0.25) time.sleep(1) pg.dragTo(1400,50,duration=1) #pg.dragRel() #以当前位置拖动 ############# #import pyperclip # 这个可以把数据保存到剪贴板 #import functools #a=functools.reduce(lambda x,y:str(x)+'\n'+str(y),[ i for i in range(500)]) #pyperclip.copy(a) #这里已经保存到剪贴板 可用notpad++黏贴 win自带文本不行》 #这里都是为 scroll 做准备 scroll 向上 scroll(负数) 向下滚动 #pg.click();time.sleep(3);pg.scroll(250) ##############屏幕处理 imagetest =pg.screenshot() rgb = imagetest.getpixel( (400,200) ) #这里传入元祖 得到一个R G B 元组 print(rgb) print ( pg.pixelMatchesColor(401,201,rgb) )