def double_check_pid(pid_number): sc.get_m2_coordinates() pyautogui.doubleClick(m2['prospect_id']) keyboard.send('ctrl + c') copied_text = clipboard.paste() for i in range(3): if copied_text != pid_number: time.sleep(0.3) pyautogui.doubleClick(m2['prospect_id']) keyboard.send('ctrl + c') copied_text = clipboard.paste() if copied_text != pid_number: input('Is the pid correct?') return if pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\company.png', region=(514, 245, 889, 566)) is not None: return pyautogui.click(m2['company']) keyboard.send('ctrl + z') time.sleep(1) keyboard.send('ctrl + c') copied_text = clipboard.paste() if 'pid' in copied_text.lower(): input('Is the pid correct?') return
def create_data_frame(): """ Takes screenshots of the tours. Turns the screenshots into a list of dictionaries 'd'. Turns 'd' into a dataframe. d is a list of dictionaries such as [{''Date': '7/06/18', 'Tour_Type': 'Audition', 'Tour_Status': 'Showed'}, {'Date': '7/06/18', 'Tour_Type': 'minivac', 'Tour_Status': 'Showed'}] :return: """ sc.get_m2_coordinates() d = [] pretty_d = [] x, y = m2['title'] for i in range(8): month = take_screenshot(x + 327, y + 63, 13, 10) day = take_screenshot(x + 342, y + 63, 15, 10) year = take_screenshot(x + 358, y + 63, 27, 10) tour_date = get_date(month, day, year) tour_type = take_screenshot(x + 402, y + 63, 14, 10) tour_status = take_screenshot(x + 484, y + 63, 14, 10) try: tour_type = sc.m2_tour_types[tour_type] except KeyError: print('Unrecognized tour type') print(tour_type) tour_type = None try: tour_status_dict = read_pickle_file('m2_tour_status.p') tour_status = tour_status_dict[tour_status] except KeyError: print('Unrecognized tour status') print(tour_status) tour_status = None y += 13 if tour_date != 'Nothing': try: # Where the screenshots get turned into dictionaries. pretty_d.append({ 'Date': tour_date, 'Tour_Type': tour_type, 'Tour_Status': tour_status }) tour_date = pd.to_datetime(tour_date) d.append({ 'Date': tour_date, 'Tour_Type': tour_type, 'Tour_Status': tour_status }) except NameError: pass df = pd.DataFrame(d) # Turn d into a dataframe df = df[['Date', 'Tour_Type', 'Tour_Status']] # Reorders the columns in the dataframe. pretty_df = pd.DataFrame(pretty_d) pretty_df = pretty_df[['Date', 'Tour_Type', 'Tour_Status']] # print(tabulate(pretty_df, headers='keys', tablefmt='psql')) return df
def site(self): sc.get_m2_coordinates() x, y = m2['title'] conn = sqlite3.connect('sqlite.sqlite') c = conn.cursor() if pyautogui.pixelMatchesColor(1318, 358, (214, 211, 206)): screenshot = cf.take_screenshot_change_color(x + 671, y + 64 + self.index * 13, 6, 9) else: screenshot = cf.take_screenshot_change_color(x + 687, y + 64 + self.index * 13, 6, 9) if screenshot != 'nothing': c.execute("SELECT name FROM numbers WHERE screenshot=?", [screenshot]) tour_site = str(c.fetchone()[0]) return tour_site
def double_check_pid(self): sc.get_m2_coordinates() x, y = m2['title'] pid_screenshot = '' conn = sqlite3.connect('sqlite.sqlite') c = conn.cursor() for i in range(7): screenshot = cf.take_screenshot_change_color(x + 74 + 6 * i, y + 48, 6, 9) c.execute("SELECT name FROM numbers WHERE screenshot=?", [screenshot]) number = str(c.fetchone()[0]) if number != 'nothing': pid_screenshot += number else: continue if pid_screenshot != self.pid: cf.pause('Is the pid correct?') return
def enter_phone_number(number): sc.get_m2_coordinates() screen_shot = None pyautogui.doubleClick(m2['phone2']) keyboard.write(number) keyboard.send('tab') pyautogui.click(m2['ok']) while screen_shot != sc.phone_error and screen_shot != sc.phone_no_error: with mss.mss() as sct: monitor = {'top': 306, 'left': 722, 'width': 38, 'height': 16} im = sct.grab(monitor) screen_shot = str(mss.tools.to_png(im.rgb, im.size)) if screen_shot == sc.phone_error: pyautogui.click(740, 313) pyautogui.click(m2['ok']) return "Error" elif screen_shot == sc.phone_no_error: return "Good"
def site(self): sc.get_m2_coordinates() x, y = m2['title'] conn = sqlite3.connect('sqlite.sqlite') c = conn.cursor() screenshot = cf.take_screenshot_change_color(x + 687, y + 64 + self.index * 13, 6, 9) if screenshot != 'nothing': try: c.execute("SELECT name FROM numbers WHERE screenshot=?", [screenshot]) tour_site = str(c.fetchone()[0]) except TypeError: screenshot = cf.take_screenshot_change_color( x + 671, y + 64 + 0 * 13, 6, 9) c.execute("SELECT name FROM numbers WHERE screenshot=?", [screenshot]) tour_site = str(c.fetchone()[0]) return tour_site
import re import csv import time from tkinter import Tk import keyboard import mss import mss.tools import pandas as pd import pyautogui import pyperclip import screenshot_data as sc from screenshot_data import m1, m2, m3, m4, m5, m6, m7, m8 import datetime d = [] sc.get_m2_coordinates() x, y = m2['title'] for i in range(5): with mss.mss() as sct: monitor = {'top': y + 63, 'left': x + 402, 'width': 14, 'height': 10} im = sct.grab(monitor) try: screenshot = sc.m2_tour_types[str(mss.tools.to_png( im.rgb, im.size))] except KeyError: print(i) print(str(mss.tools.to_png(im.rgb, im.size))) screenshot = None monitor = {'top': y + 63, 'left': x + 484, 'width': 14, 'height': 10} im = sct.grab(monitor) try:
def create_accommodations_dataframe(): """ Takes screenshots of the tours. Turns the screenshots into a list of dictionaries 'd'. Turns 'd' into a dataframe. d is a list of dictionaries such as [{''Date': '7/06/18', 'Tour_Type': 'Audition', 'Tour_Status': 'Showed'}, {'Date': '7/06/18', 'Tour_Type': 'minivac', 'Tour_Status': 'Showed'}] :return: """ sc.get_m2_coordinates() d = [] pretty_d = [] x, y = m2['title'] for i in range(8): # Take screenshots of dates month = take_screenshot(x + 327, y + 63, 13, 10) day = take_screenshot(x + 342, y + 63, 15, 10) year = take_screenshot(x + 358, y + 63, 27, 10) # Turn the screenshots into a datetime object tour_date = turn_screenshots_into_date(month, day, year) # Take screenshots of the tour type and tour status tour_type = take_screenshot(x + 402, y + 63, 14, 10) tour_status = take_screenshot(x + 484, y + 63, 14, 10) # TODO Use pickle file here instead of dictionary in screenshot_data. # Turn screenshot of tour type into string using the dictionary m2_tour_types try: tour_type = sc.m2_tour_types[tour_type] except KeyError: print('Unrecognized tour type') print(tour_type) tour_type = None # Turn screenshot of tour status into string using the pickle file m2_tour_status try: tour_status_dict = read_pickle_file('m2_tour_status.p') tour_status = tour_status_dict[tour_status] except KeyError: print('Unrecognized tour status') print(tour_status) tour_status = None y += 13 # Turns the screenshots into dictionaries. if tour_date != 'Nothing': try: # pretty_d uses strings instead of datetime objects because strings look better. pretty_d.append({'Date': tour_date, 'Tour_Type': tour_type, 'Tour_Status': tour_status}) # Turn strings into datetime objects and creates the dictionaries for the actual dataframe. tour_date = pd.to_datetime(tour_date) d.append({'Date': tour_date, 'Tour_Type': tour_type, 'Tour_Status': tour_status}) except NameError: pass elif tour_status == 'Error': pretty_d.append({'Date': '', 'Tour_Type': '', 'Tour_Status': 'Error'}) d.append({'Date': '', 'Tour_Type': '', 'Tour_Status': 'Error'}) # Turns d into a dataframe and then reorders the columns in the dataframe. df = pd.DataFrame(d) df = df[['Date', 'Tour_Type', 'Tour_Status']] # Turns pretty_d into a dataframe and then reorders the columns in the dataframe. pretty_df = pd.DataFrame(pretty_d) pretty_df = pretty_df[['Date', 'Tour_Type', 'Tour_Status']] # Prints the pretty dataframe, returns the actual dataframe. return df, pretty_df
def check_for_duplicate_personnel(df, status): sc.get_m3_coordinates() pyautogui.click(m3['title']) sc.get_m2_coordinates() select_tour(df, status)
def enter_m2_info(): df = convert_excel_to_dataframe() switch_site(df.loc[0, 'Site']) insert_new_pid() sc.get_m2_coordinates(True) # Menu 2 - Prospect pyautogui.click(m2['last_name']) keyboard.write(df.loc[0, 'Last_Name']) pyautogui.click(m2['first_name']) keyboard.write(df.loc[0, 'First_Name']) pyautogui.click(m2['address']) keyboard.write(df.loc[0, 'Address']) pyautogui.click(m2['city']) keyboard.write(df.loc[0, 'City']) pyautogui.click(m2['state']) pyautogui.click(m2['postal_code']) keyboard.write(str(df.loc[0, 'Zip'])) pyautogui.click(m2['country']) for i in range(5): keyboard.send('u') pyautogui.click(m2['phone1']) keyboard.write(df.loc[0, 'Phone']) if str(df.loc[0, 'Phone_2']) != 'nan': pyautogui.click(m2['phone2']) keyboard.write(df.loc[0, 'Phone_2']) if str(df.loc[0, 'Email']) != 'nan': pyautogui.click(m2['email']) keyboard.write(df.loc[0, 'Email']) pyautogui.click(m2['demographics']) # Menu 2 - Demographics pyautogui.click(m2['marital_status']) if df.loc[0, 'Marital_Status'] == 'sm': for i in range(2): keyboard.send('s') else: keyboard.send(df.loc[0, 'Marital_Status']) pyautogui.click(m2['marital_status']) pyautogui.click(m2['spouse']) keyboard.write(('{} {}'.format(df.loc[0, 'Spouse_First_Name'], df.loc[0, 'Spouse_Last_Name']))) pyautogui.click(m2['occupation']) keyboard.send('e') pyautogui.click(m2['income']) keyboard.write('70') x, y = m2['income'] pyautogui.click(x, y + 25) keyboard.send('e') pyautogui.click(m2['notes_co']) pyautogui.click(m2['insert_coprospects']) # Menu 4 - Adding a co-prospect sc.get_m5_coordinates() pyautogui.click(m5['get_from_prospect']) pyautogui.click(m5['first']) keyboard.write(df.loc[0, 'Spouse_First_Name']) pyautogui.click(m5['ok']) sc.get_m2_coordinates(True) pyautogui.click(m2['insert_tour']) # Menu 3 - Adding a Tour Record sc.get_m3_coordinates() pyautogui.click(m3['campaign']) # Menu 4 - Select a Campaign sc.get_m4_coordinates() pyautogui.click(m4['clear']) pyautogui.click(m4['campaign']) keyboard.write('bttordm') pyautogui.click(m4['select']) # Menu 3 - Adding a Tour Record sc.get_m3_coordinates() pyautogui.click(m3['tour_type']) keyboard.send('m') pyautogui.click(m3['tour_status']) keyboard.write('b') pyautogui.click(m3['tour_date']) keyboard.write(df.loc[0, 'Tour_Date']) pyautogui.click(m3['tour_location']) for i in range(5): keyboard.send('down') pyautogui.click(m3['wave']) if df.loc[0, 'Tour_Time'] == "800": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_800.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "815": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_815.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "830": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_830.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "900": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_900.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "915": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_915.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "930": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_930.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "1030": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_1030.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "1045": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_1045.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "1130": pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_1130.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "1145": pyautogui.click(m3['scroll_bar_wave']) pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_1145.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "1230": pyautogui.click(m3['scroll_bar_wave']) pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_1230.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "1300": pyautogui.click(m3['scroll_bar_wave']) pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_1300.png', region=(514, 245, 889, 566))) elif df.loc[0, 'Tour_Time'] == "1315": pyautogui.click(m3['scroll_bar_wave']) pyautogui.click( pyautogui.locateCenterOnScreen( 'C:\\Users\\Jared.Abrahams\\Screenshots\\sc_1315.png', region=(514, 245, 889, 566)))