def description(self): x, y = m3['title'] screenshot = cf.take_screenshot_change_color(x + 266, y + 68 + 13 * self.index, 154, 10) conn = sqlite3.connect('sqlite.sqlite') c = conn.cursor() try: c.execute("SELECT name FROM deposits WHERE screenshot=?", [screenshot]) description = c.fetchone()[0] return description except TypeError: clipboard.copy('bad') pyautogui.click(x + 266, y + 68 + 13 * self.index) pyautogui.click(m3['change_deposit']) sc.get_m6_coordinates() pyautogui.click(m6['description']) keyboard.send('ctrl + z') keyboard.send('ctrl + c') r = Tk() description = r.selection_get(selection="CLIPBOARD") while description == 'bad': pyautogui.click(m6['description']) keyboard.send('ctrl + z') keyboard.send('ctrl + c') description = r.selection_get(selection="CLIPBOARD") pyautogui.click(m6['ok']) return description
def create_deposit_dataframe(): sc.get_m3_coordinates() x, y = m3['deposit_1'] x_2, y_2 = m3['title'] d = [] number_of_deposits = count_deposits() if number_of_deposits == 0: number_of_refundable_deposits = 0 return 'No Deposits', number_of_refundable_deposits for i in range(number_of_deposits): clipboard.copy('bad') hundreds = str( sqlite_select( cf.take_screenshot_change_color(x_2 + 467, y_2 + 69 + i * 13, 6, 9), 'numbers')) tens = str( sqlite_select( cf.take_screenshot_change_color(x_2 + 473, y_2 + 69 + i * 13, 6, 9), 'numbers')) ones = str( sqlite_select( cf.take_screenshot_change_color(x_2 + 479, y_2 + 69 + i * 13, 6, 9), 'numbers')) if hundreds == 'nothing': hundreds = '' if tens == 'nothing': tens = '' price = hundreds + tens + ones pyautogui.click(x, y) y += 13 pyautogui.click(m3['change_deposit']) sc.get_m6_coordinates() pyautogui.click(m6['description']) keyboard.send('ctrl + z') keyboard.send('ctrl + c') r = Tk() result = r.selection_get(selection="CLIPBOARD") while result == 'bad': pyautogui.click(m6['description']) keyboard.send('ctrl + z') keyboard.send('ctrl + c') result = r.selection_get(selection="CLIPBOARD") if 'refunded' in result.lower(): deposit_type = 'Refunded' elif 'minivac' in result.lower() or 'apply' in result.lower(): deposit_type = 'Non_Refundable' elif 'ref' in result.lower(): deposit_type = 'Refundable' else: deposit_type = 'Non_Refundable' d.append({'Deposit_Type': deposit_type, 'Price': price}) pyautogui.click(m6['ok']) df = pd.DataFrame(d) # Turn d into a dataframe deposit_df = df[['Deposit_Type', 'Price']] # Reorders the columns in the dataframe. number_of_refundable_deposits = len(df[(df.Deposit_Type == 'Refundable')]) return deposit_df, number_of_refundable_deposits
def count_items_in_deposit(): sc.get_m6_coordinates() number_of_deposit_items = 0 x, y = m6['title'] while True: screenshot = cf.take_screenshot(x + 339, y + 189, 10, 8) if screenshot == sc.no_deposit_items: return number_of_deposit_items else: number_of_deposit_items += 1 y += 13
def count_deposit_items(): sc.get_m6_coordinates() number_of_deposit_items = 0 x, y = m6['title'] while True: with mss.mss() as sct: monitor = {'top': y + 189, 'left': x + 339, 'width': 10, 'height': 8} im = sct.grab(monitor) screenshot = str(mss.tools.to_png(im.rgb, im.size)) if screenshot == sc.no_deposit_items: return number_of_deposit_items else: number_of_deposit_items += 1 y += 13
def copy_reference_number(): deposit_item_amount = count_deposit_items() sc.get_m6_coordinates() x, y = m6['deposit_1'] y = y + 13 * (deposit_item_amount - 1) pyautogui.click(x, y) keyboard.send('alt + v') sc.get_m7_coordinates() pyautogui.doubleClick(m7['reference']) keyboard.press_and_release('ctrl + c') time.sleep(0.5) old_reference = clipboard.paste() old_reference = old_reference.upper() if old_reference[0] != 'D': sys.exit("Wrong Reference") new_reference = old_reference.replace("D-", "R-") clipboard.copy(str(new_reference)) pyautogui.click(m7['cancel'])
def use_excel_sheet(): scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'] creds = ServiceAccountCredentials.from_json_keyfile_name('Phone-6ad41718c799.json', scope) client = gspread.authorize(creds) sheet = client.open("Reflections").sheet1 dictionaries = sheet.get_all_records() number_of_rows = len(sheet.get_all_records()) progress = 1 index = 1 for row in dictionaries: pid, price, cash, completed = str(row['pid']), row['price'], row['cash'], row['completed'] if row['date'] != '': date = datetime.datetime.strptime(row['date'] + '/18', "%m/%d/%y") if completed in ['x', 'X']: progress += 1 continue show_progress(pid, progress, number_of_rows) if cash != '': cash_or_cc = 'cash' else: cash_or_cc = 'cc' search_pid(pid) cf.double_check_pid(pid) select_tour(1, date) if cash_or_cc == 'cc': deposit_type = change_deposit_title(price) else: deposit_type = change_deposit_title(price, cash) if deposit_type == 'fail': select_tour(2, date) if cash_or_cc == 'cc': deposit_type = change_deposit_title(price) else: deposit_type = change_deposit_title(price, cash) if deposit_type != 'prev' and cash_or_cc == 'cc': copy_reference_number() elif cash_or_cc == 'cash': clipboard.copy('R-CASH') else: with open('Deposit_Errors.txt', 'a') as out: out.write('{}\n'.format(pid)) sc.get_m6_coordinates() pyautogui.click(m6['ok']) 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) # ams_ir_or_sol = input('ams, ir, or sol:') # old_reference = input('Reference Number starting with D:') # reference_number = old_reference.replace("D-", "R-") # if ams_ir_or_sol == 'ams': # select_ams_refund_payment(date, price, 'ams', reference_number) # elif ams_ir_or_sol == 'ir': # select_ams_refund_payment(date, price, 'ir', reference_number) # elif ams_ir_or_sol == 'sol': # select_ams_refund_payment(date, price, 'sol', reference_number) if deposit_type == 'ams': select_ams_refund_payment(date, price, 'ams') elif deposit_type == 'ir': select_ams_refund_payment(date, price, 'ir') elif deposit_type == 'sol': select_ams_refund_payment(date, price, 'sol') elif deposit_type == 'ih': select_ams_refund_payment(date, price, 'ih') mark_row_as_completed(index) progress += 1
def select_ir_refund_payment(date, price, reference_number=None): sc.get_m6_coordinates() image = None pyautogui.click(m6['insert']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) attempts = 0 global transaction_code if transaction_code == 0 or transaction_code == 1: 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 = 1 else: transaction_code = 0 if transaction_code == 0 or transaction_code == 2: attempts = 0 pyautogui.click(m8['cancel']) 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 = 2 else: transaction_code = 0 sys.exit("Couldn't find correct choice") pyautogui.click(image) if transaction_code == 1: 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 now = datetime.datetime.now() now_str = now.strftime("%Y-%m-%d-%H-%M-%S") outfile = pyautogui.screenshot( 'C:\\Users\\Jared.Abrahams\\work\\deposit_screenshots\\ImageFile{}.png'.format(now_str)) 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 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': 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] == 'ir 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 == '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 change_deposit_title(price, cash=None): """ Checks to make sure that the deposit price is correct. Ex: If the sheet says $50, then this makes sure that the deposit is also $50. Changes the title from 'Refundable' to 'Refunded' :rtype: 'prev', 'ams', 'ir', 'sol', 'ih' """ sc.get_m3_coordinates() amount = 0 old_title = 'old' x, y = m3['title'] attempts = 0 number_of_deposits = count_deposits() pyautogui.click(m3['tour_packages']) image = pyautogui.locateCenterOnScreen('C:\\Users\\Jared.Abrahams\\Screenshots\\balance.png', region=(700, 245, 850, 566)) while image is None: image = pyautogui.locateCenterOnScreen('C:\\Users\\Jared.Abrahams\\Screenshots\\balance.png', region=(700, 245, 850, 566)) for i in range(number_of_deposits): hundreds = str(sqlite_select(cf.take_screenshot_change_color(x + 467, y + 69 + i * 13, 6, 9), 'numbers')) tens = str(sqlite_select(cf.take_screenshot_change_color(x + 473, y + 69 + i * 13, 6, 9), 'numbers')) ones = str(sqlite_select(cf.take_screenshot_change_color(x + 479, y + 69 + i * 13, 6, 9), 'numbers')) if hundreds == 'nothing': hundreds = '' if tens == 'nothing': tens = '' amount = hundreds + tens + ones if amount == price: x_2, y_2 = m3['deposit_1'] pyautogui.click(x_2, y_2 + i * 13) pyautogui.click(m3['change_deposit']) break while amount != price and attempts <= 2: pyautogui.click(m3['tour_packages']) image = pyautogui.locateCenterOnScreen('C:\\Users\\Jared.Abrahams\\Screenshots\\balance.png', region=(700, 245, 850, 566)) while image is None: image = pyautogui.locateCenterOnScreen('C:\\Users\\Jared.Abrahams\\Screenshots\\balance.png', region=(700, 245, 850, 566)) pyautogui.click(x_2, y_2) pyautogui.click(m3['change_deposit']) sc.get_m6_coordinates() deposit_item_amount = count_deposit_items() x, y = m6['deposit_1'] y = y + 13 * (deposit_item_amount - 1) pyautogui.click(x, y) time.sleep(0.3) with mss.mss() as sct: # Takes screenshot of lowest amount inside of the deposit x, y = m6['title'] y = y + 13 * (deposit_item_amount - 1) monitor = {'top': y + 189, 'left': x + 185, 'width': 33, 'height': 8} im = sct.grab(monitor) try: amount = sc.deposit_item_amount[str(mss.tools.to_png(im.rgb, im.size))] except KeyError: amount = 0 print('Don\'t recognize the amount') print(mss.tools.to_png(im.rgb, im.size)) print(deposit_item_amount, x, y) output = 'monitor-1-crop.png' mss.tools.to_png(im.rgb, im.size, output=output) attempts += 1 if amount != price: pyautogui.click(m3['ok']) return 'fail' attempts = 0 while 'ref' not in old_title.lower() and attempts <= 3: pyautogui.click(m6['description']) keyboard.send('ctrl + z') keyboard.send('ctrl + c') old_title = clipboard.paste() attempts += 1 if 'ref' not in old_title.lower(): if old_title.lower() == 'ams dep': old_title = 'AMS/Refunded Deposit' else: sys.exit("Wrong Title") new_title = old_title.replace("able", "ed") new_title = new_title.replace("ABLE", "ED") new_title = new_title.replace(" /", "/") new_title = new_title.replace("/ ", "/") keyboard.write(new_title) if 'prev' in new_title.lower() and cash is None: return 'prev' elif 'ir' in new_title.lower() and 'refunded' in new_title.lower(): return "ir" elif 'ams' in new_title.lower() and 'refunded' in new_title.lower(): return "ams" elif 'sol' in new_title.lower() and 'refunded' in new_title.lower(): return "sol" elif 'ih' in new_title.lower() and 'refunded' in new_title.lower(): return 'ih'
def apply_to_mv(deposit_df): pyautogui.click(m3['tour_packages']) pyautogui.click(m3['deposit_1']) pyautogui.click(m3['change_deposit']) deposit_item_amount = count_items_in_deposit() sc.get_m6_coordinates() x, y = m6['deposit_1'] y = y + 13 * (deposit_item_amount - 1) pyautogui.click(x, y) keyboard.send('alt + v') sc.get_m7_coordinates() pyautogui.doubleClick(m7['reference']) keyboard.press_and_release('ctrl + c') time.sleep(0.5) old_reference = clipboard.paste() old_reference = old_reference.upper() if old_reference[0] != 'D': sys.exit("Wrong Reference") new_reference = old_reference.replace("D-", "U-") clipboard.copy(str(new_reference)) pyautogui.click(m7['cancel']) sc.get_m6_coordinates() pyautogui.click(m6['description']) keyboard.send('ctrl + z') keyboard.send('ctrl + c') r = Tk() old_description = r.selection_get(selection="CLIPBOARD") if 'AMS' in old_description: keyboard.write('AMS/Minivac') pyautogui.click(m6['payment']) sc.get_m8_coordinates() pyautogui.click(m8['transaction_code']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\apply_to_mv.png', region=(136, 652, 392, 247)) while image is None: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\apply_to_mv.png', region=(136, 652, 392, 247)) pyautogui.click(image) pyautogui.click(m8['reference']) keyboard.write('APPLY TO MV') pyautogui.click(m8['ok']) time.sleep(0.3) pyautogui.click(880, 565) pyautogui.click(m6['payment']) sc.get_m8_coordinates() time.sleep(0.3) pyautogui.click(m8['transaction_code']) image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_credit_payment.png', region=(136, 652, 392, 247)) while image is None: image = pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\ams_credit_payment.png', region=(136, 652, 392, 247)) pyautogui.click(image) pyautogui.doubleClick(m8['amount']) keyboard.write(deposit_df.Price[0]) pyautogui.click(m8['reference']) keyboard.write(new_reference) cf.pause('Ok?') pyautogui.click(m8['ok']) sc.get_m6_coordinates() pyautogui.click(m6['ok']) print('Applied Refundable Deposit to Minivac') deposit_df.Deposit_Type[0] = 'Non_Refundable'
def use_excel_sheet(): scope = [ 'https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive' ] creds = ServiceAccountCredentials.from_json_keyfile_name( 'Phone-6ad41718c799.json', scope) client = gspread.authorize(creds) sheet = client.open("Reflections").sheet1 convert_excel_to_csv() number_of_pids = count_number_of_pids() progress = 1 with open('file.csv') as csvfile: reader = csv.DictReader(csvfile) for row in reader: if row['Completed'] == 'x': progress += 1 continue pids = row['PID'].replace('.0', '') price = row['price'] date = row['date'] date = datetime.datetime.strptime(date, '%Y-%m-%d').strftime('%m/%d') cash = row['cash'] index = row[''] formatted_progress = show_progress(pids, progress, number_of_pids) print('{} - {}\n'.format(price, date)) if cash == 'x' or cash == 'X': cash_or_cc = 'cash' else: cash_or_cc = 'cc' search_pid(pids) double_check_pid(pids) df = create_data_frame() select_tour(df, 1, date) if cash_or_cc == 'cc': deposit_type = change_deposit_title(price) else: deposit_type = change_deposit_title(price, cash) if deposit_type == 'fail': select_tour(df, 2, date) if cash_or_cc == 'cc': deposit_type = change_deposit_title(price) else: deposit_type = change_deposit_title(price, cash) if deposit_type != 'prev' and cash_or_cc == 'cc': copy_reference_number() elif cash_or_cc == 'cash': clipboard.copy('R-CASH') else: with open('Deposit_Errors.txt', 'a') as out: out.write('{}\n'.format(pids)) sc.get_m6_coordinates() pyautogui.click(m6['ok']) 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) # ams_ir_or_sol = input('ams, ir, or sol:') # old_reference = input('Reference Number starting with D:') # reference_number = old_reference.replace("D-", "R-") # if ams_ir_or_sol == 'ams': # select_ams_refund_payment(date, price, 'ams', reference_number) # elif ams_ir_or_sol == 'ir': # select_ams_refund_payment(date, price, 'ir', reference_number) # elif ams_ir_or_sol == 'sol': # select_ams_refund_payment(date, price, 'sol', reference_number) if deposit_type == 'ams': select_ams_refund_payment(date, price, 'ams') elif deposit_type == 'ir': select_ams_refund_payment(date, price, 'ir') elif deposit_type == 'sol': select_ams_refund_payment(date, price, 'sol') elif deposit_type == 'ih': select_ams_refund_payment(date, price, 'ih') mark_row_as_completed(index) sheet.update_cell(2, 1, formatted_progress) progress += 1