From c146cdf9b2df9bdd571dcb65746c8aaef9e52e8e Mon Sep 17 00:00:00 2001 From: airopathfitz <52722008+airopathfitz@users.noreply.github.com> Date: Thu, 18 Jul 2019 12:52:31 -0700 Subject: [PATCH 1/3] Add files via upload ComboScript 5.1 is the main file. It imports VisioNameTool's contents in, must be in the same folder location. The main function starts in a KeyPress while loop. Depending on the input, 1 or 2, the code runs the Visio Name Tool or the AutoColoring. The VisioNameTool is code straight from the ComboScript3.0, WITHOUT the Creator() function method and the Pause() method. Also removed the bottom GUI() call, will now be called in the main() while loop. Includes 2 classes. The first class: Options has all the main code from the original AutoScripts. Added an area for functionality for saving coloring data to an excel sheet and calculating the audit totals. The second class: AutoColor houses the GUI for the actual coloring. The user chooses what the majority color of APs are and the code will color the rest. Main() runs the whole program --- AutoScript/ComboScript 5.1.py | 272 ++++++++++++++++++++++++++++++++++ AutoScript/VisioNameTool.py | 184 +++++++++++++++++++++++ 2 files changed, 456 insertions(+) create mode 100644 AutoScript/ComboScript 5.1.py create mode 100644 AutoScript/VisioNameTool.py diff --git a/AutoScript/ComboScript 5.1.py b/AutoScript/ComboScript 5.1.py new file mode 100644 index 0000000..7584ad3 --- /dev/null +++ b/AutoScript/ComboScript 5.1.py @@ -0,0 +1,272 @@ +import keyboard, openpyxl, pyautogui, tkinter, time +from tkinter import filedialog, messagebox, Tk +from openpyxl import Workbook, load_workbook + +class Options: + def open_audit_sheet (self): #Opens a file explorer and returns path from chosen file + global audit_sheet + Tk().withdraw() # We don't want a full GUI, so keep the root window from appearing + xlname = filedialog.askopenfilename() # Show an "Open" dialog box and return the path to the selected file + print("Loading Excell File... ") + audit_book = load_workbook(xlname)#Opens Excel + audit_sheet = audit_book['Audit'] #grabs information from the "audit" sheet + + def audit_sheet_sorter (self): #reads all AP's from chosen Audit Sheet and categories them by their color + global AP_red_list + global AP_blue_list + global AP_green_list + global AP_orange_list + + xlname_col = 'A' #column letter to read AP names from + xlname_col_fail = 'K' #column letter to read fails from + xlname_row = int('3') #Starting row in excel + xlname_row_fail = int('3') #Starting row in excel + + AP_red_list = [] #initiates a list for green AP's ('2') + AP_blue_list = [] #initiates a list for green AP's ('4') + AP_green_list = [] #initiates a list for green AP's ('1') + AP_orange_list = [] #initiates a list for green AP's ('3') + + AP_red_count_list = int('0')#Keeps track how long the list is + AP_blue_count_list = int('0') + AP_green_count_list = int('0') + AP_orange_count_list = int('0') + + print("List of Failed AP ID's:") + for AP in range (0,15): #range of APS being colored + xlname_col_fail_num = str(xlname_col_fail) + str(xlname_row_fail) + xlname_col_num = str(xlname_col) + str(xlname_row) + cell_value1 = audit_sheet[xlname_col_fail_num] + cell_value2 = audit_sheet[xlname_col_num] + AP_fail = cell_value1.value + AP_ID = cell_value2.value + + if AP_fail == 1: #reads all green AP's + AP_green_list.append(AP_ID) + print(AP_green_list[AP_green_count_list]) + AP_green_count_list += 1 + + elif AP_fail == 2: #reads all red AP's + AP_red_list.append(AP_ID) + print(AP_red_list[AP_red_count_list]) + AP_red_count_list += 1 + + elif AP_fail == 3: #reads all orange AP's + AP_orange_list.append(AP_ID) + print(AP_orange_list[AP_orange_count_list]) + AP_orange_count_list += 1 + + elif AP_fail == 4: #reads all blue AP's + AP_blue_list.append(AP_ID) + print(AP_blue_list[AP_blue_count_list]) + AP_blue_count_list += 1 + + else: + print('End of Audit Sheets') + break + xlname_row_fail += 1 + xlname_row += 1 + + def search_options (self): #sets visio to search all pages for AP IDs, must be done before coloring + print ("\nStarting Search...") + pyautogui.hotkey('ctrl', 'f') + pyautogui.press(['tab','tab']) + pyautogui.press('down') + pyautogui.press('esc') + + def auto_script_green(self): #finds AP name in Visio and colors it GREEN, + AP_green_count = 0 + for x in AP_green_list: + AP_num = AP_green_list[AP_green_count] + AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. + print(AP_num_print) + pyautogui.hotkey('ctrl', 'f') + pyautogui.typewrite(AP_num_print) + pyautogui.press(['enter', 'esc','esc','tab','enter']) + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('alt', 'h')#line coloring + pyautogui.press(['l','down','down','down','down','down','down','down','left','enter']) + pyautogui.hotkey('alt', 'h')#fill coloring + pyautogui.press(['i','down','down','down','down','down','down','down','left','enter']) + AP_green_count += 1 #adds one to total green count + print(f'Green APs: {AP_green_count}') + + def auto_script_red(self): #finds AP name in Visio and colors it RED, + AP_red_count = 0 + for x in AP_red_list: #finds AP name in Visio and colors it + AP_num = AP_red_list[AP_red_count] + AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. + print(AP_num_print) + pyautogui.hotkey('ctrl', 'f') + pyautogui.typewrite(AP_num_print) + pyautogui.press(['enter', 'esc','esc','tab','enter']) + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('alt', 'h')#line coloring + pyautogui.press(['l','down','down','down','down','down','down','down','left','left','left','left','enter']) + pyautogui.hotkey('alt', 'h')#fill coloring + pyautogui.press(['i','down','down','down','down','down','down','down','left','left','left','left','enter']) + AP_red_count += 1 #adds one to total red count + print(f'Red APs: {AP_red_count}') + + def auto_script_orange(self): #finds AP name in Visio and colors it ORANGE, + AP_orange_count = 0 + for x in AP_orange_list: #finds AP name in Visio and colors it + AP_num = AP_orange_list[AP_orange_count] + AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. + print(AP_num_print) + pyautogui.hotkey('ctrl', 'f') + pyautogui.typewrite(AP_num_print) + pyautogui.press(['enter', 'esc','esc','tab','enter']) + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('alt', 'h')#line coloring + pyautogui.press(['l','down','down','down','down','down','down','down','left','left','left','enter']) + pyautogui.hotkey('alt', 'h')#fill coloring + pyautogui.press(['i','down','down','down','down','down','down','down','left','left','left','enter']) + AP_orange_count += 1 # adds one to total orange count + print(f'Orange APs: {AP_orange_count}') + + def auto_script_blue(self): #finds AP name in Visio and colors it BLUE, + AP_blue_count = 0 + for x in AP_blue_list: + AP_num = AP_blue_list[AP_blue_count] + AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. + print(AP_num_print) + pyautogui.hotkey('ctrl', 'f') + pyautogui.typewrite(AP_num_print) + pyautogui.press(['enter', 'esc','esc','tab','enter']) + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('shift','tab','enter') + pyautogui.hotkey('alt', 'h')#line coloring + pyautogui.press(['l','down','down','down','down','down','down','down','right','enter']) + pyautogui.hotkey('alt', 'h')#fill coloring + pyautogui.press(['i','down','down','down','down','down','down','down','right','enter']) + AP_blue_count += 1 #adds one to total blue count + print(f'Blue APs: {AP_blue_count}') + + #def auto_script_total(self): + #print(f'Total APs: ') + #print(f'Total Failed APs:') + def save_new_sheet(self): #Pop-up message box, asks if user wants to save sorted date to new excell file/sheet + result = messagebox.askyesno("Visio AP Coloring Tool","Do you want to save data in new Excell?") + print(result) + if result == True: + print("data saved in 'New File'") + + else: + pass + + +class AutoColor(tkinter.Frame): #POP-UP GUI for choosing majority of Sheets color + def __init__(self, master=None): + super().__init__(master) + self.master = master + + #master = messagebox("Visio AP Coloring Tool\nSelect the AP color majority: ") + self.pack() + self.create_widgets() + + def create_widgets(self): #buttons in the GUI + #self.title.pack(text="""""", justify = Tk.LEFT, padx = 20) + + self.title = tkinter.Label(self, text = "Choose AP Color Majority: ") + self.title.pack(side = "top") + + self.option1 = tkinter.Button(self, fg = "green") #Button, colored green + self.option1["text"] = "Green" #button, named green + self.option1["command"] = self.output1 #when button pressed, execute output1 + self.option1.pack(side="top") #position selt at top most position + + self.option2 = tkinter.Button(self, text = "Red", fg = "red", command = self.output2) #better formatted buttons + self.option2.pack(side="top") + + self.option3 = tkinter.Button(self, text = "Orange", fg = "orange", command = self.output3) + self.option3.pack(side="top") + + self.option4 = tkinter.Button(self, text = "Blue", fg = "blue", command = self.output4) + self.option4.pack(side="top") + + self.quit = tkinter.Button(self, text="QUIT", fg="red", command=self.close) + self.quit.pack(side="bottom", pady = 30) + + def output1(self): #colors all but green + print("GREEN AP Majority...") + print("QUICK! You have 5 seconds to click into your visio file!!!\n") + time.sleep(5) + Options.auto_script_red(self) + Options.auto_script_orange(self) + Options.auto_script_blue(self) + self.close() + + def output2(self): #colors all but red + print("RED AP Majority...") + print("QUICK! You have 5 seconds to click into your visio file!!!\n") + time.sleep(5) + Options.auto_script_green(self) + Options.auto_script_blue(self) + Options.auto_script_orange(self) + self.close() + + def output3(self): #colors all but orange + print("Orange AP Majority...") + print("QUICK! You have 5 seconds to click into your visio file!!!\n") + time.sleep(5) + Options.auto_script_green(self) + Options.auto_script_red(self) + Options.auto_script_blue(self) + self.close() + + def output4(self): #colors all but blue + print("Blue AP Majority...") + print("QUICK! You have 5 seconds to click into your visio file!!!\n") + time.sleep(5) + Options.auto_script_green(self) + Options.auto_script_red(self) + Options.auto_script_orange(self) + Options.save_new_sheet(self) + self.close() + + def close(self): + print("Closing program... Have a nice day :)") + time.sleep(1) + exit(0) + + +def main(): + #choice = "" #creates a blank string for user input + keyPress = "" + #while choice != "3": + while keyPress != "3": + print("Enter '1' to open Visio AP Naming tool") + print("Enter '2' to open Visio AP Coloring tool") + print("Enter '3' to quit program\n") + #choice = input(">>> ") + keyPress = keyboard.read_key() + if keyPress == "1": + import VisioNameTool as vnt + vnt.theGUI() #the GUI function calls these internally: + break #vnt.startWorkbook() + #vnt.openFiles() + #vnt.visioLoop() + #vnt.visioGuts() + #vnt.saveExcel() + elif keyPress == "2": + #AutoColor Tool + start = Options() + start.open_audit_sheet() + start.audit_sheet_sorter() + start.search_options() + root = tkinter.Tk() + A_C = AutoColor(master=root) + A_C.master.title("Visio AP Coloring Tool") + A_C.mainloop() + break + + else: + print("Invalid input") + pass + +if __name__ == "__main__": + main() diff --git a/AutoScript/VisioNameTool.py b/AutoScript/VisioNameTool.py new file mode 100644 index 0000000..2a8c3f6 --- /dev/null +++ b/AutoScript/VisioNameTool.py @@ -0,0 +1,184 @@ +import pyautogui, time, openpyxl, keyboard, datetime, sys, os +from openpyxl import Workbook +from tkinter import filedialog, Tk +from guizero import App, Text, TextBox, PushButton, Window + +global siteName +global apPrefix +global apNumber +global apName +global excelCount +global excelNumber +global rowLetter +global rowNumber +global rowWholeName +global list +global excelName +global formatNumber +global excelStartingInteger +global keyPress + +siteName = str ('Paul') +apPrefix = siteName + '-XX-' +apNumber = int('1') +apName = str(apPrefix) + str(apNumber) +excelCount = int('1') +excelNumber = int('1') +rowLetter = 'A' +rowNumber = int('1') + +rowWholeName = str(rowLetter) + str(rowNumber) +list=[99999] +excelName = 'Paul' +formatNumber = format(apNumber, '05') +excelStartingInteger = int('1') +currentTime = datetime.datetime.now().strftime("%Y-%m-%d %H.%M.%S") + +def startWorkbook ():#Starts an excel. Required for visioTool. + global wb + wb = Workbook() + global ws + ws = wb.active + +def openFiles():#Opens file explorer + global excelName + #Tk().withdraw() # We don't want a full GUI, so keep the root window from appearing + excelName = filedialog.askopenfilename() # Show an "Open" dialog box and return the path to the selected file + print(excelName) + print('') + +def pause(): #Pause logic + keyPress = keyboard.read_key() + if keyPress == 'pause': #Reads if pause button has been pressed and unpauses + print('Unpaused') + time.sleep(.3) + exit + else: #If pause has not been pressed then loop repeats infinitely WOO + pause() + +def theGUI(): #all the GUI stuff + print('') + print('Start of Visio Tool') + def apStartingNumber(): # part of GUI that allows changing of the starting AP number + global apNumber + global formatNumber + apNumber = int(startingNumber.value) + formatNumber = format(apNumber, '05') + print ('AP number changed to ' + str(apNumber)) + changingText.value = "AP number changed to " + str(apNumber) #Text for changing AP number + + def changeSiteName(): # part of GUI that allows changing of the site name + global siteName + global apPrefix + global apName + siteName = str(siteNames.value) + apPrefix = siteName + '-XX-' + apName = str(apPrefix) + str(apNumber) + print('Site name changed to ' + siteName) + changingText.value = "Site changed to " + siteName #Text for changing site name + + def directions(): #Once "Go?" has been pressed execute the following items + startWorkbook() + openFiles() + app.hide() + visioLoop() + python = sys.executable #Restarts the whole program + os.execl(python, python, * sys.argv) #Restarts the whole program + + app = App(title = "Phoenix_Oath", width=352, height=132, layout='grid') + + button7 = PushButton(app, text = "Go?", command = directions, grid=[2,3]) + + #Logic for changing starting AP number + startingNumberText = Text(app, text="AP Number?", align="left", grid=[0,1]) #Text asks for AP number + startingNumber = TextBox(app, align="right",text = "1", width=30, grid=[1,1]) #Text box for data entry + button4 = PushButton(app, text = "Confirm", command = apStartingNumber, grid=[2,1]) + + #Logic for changing site name + siteNamesText = Text(app, text="Site Name?", align="left", grid=[0,2]) #Text asks for site name + siteNames = TextBox(app, align="right",text = "PAUL", width=30, grid=[1,2]) #Text box for data entry + button6 = PushButton(app, text = "Confirm", command = changeSiteName, grid=[2,2]) + + changingText = Text(app,text="War has changed", align ="left", grid=[1,3]) + app.display() # initiates the GUI. Allowing it to be used + +def saveExcel(): # saves Visio Tool names to Excel + global displayText + global excelName + wb.save(excelName) # Saves workbook + print ('') + print ('Worksheet saved') + print ('End of Visio Tool') + +def visioGuts(): # the internals to the Visio Tool. Determines how most of the program is run + global apNumber + global formatNumber + global excelStartingInteger + print (apName) + ws.cell(excelStartingInteger, 1, apName) #writes in excel **format** ->(row, column, content to be written in cell) + pyautogui.press('backspace'); pyautogui.typewrite(str(formatNumber)) # takes control of keyboard. hits backspace and types AP number + apNumber += 1 #increments ap number up by 1 + excelStartingInteger += 1 # Increments Excel cell to be written in + formatNumber = format(apNumber, '05') # Modifies apNumber by adding up to 5 zeros in front + +def visioLoop(): + global apNumber + global formatNumber + global excelStartingInteger + global apName + while True: + keyPress = keyboard.read_key() #reads ALL keypress's and saves to variable + + if keyPress == '`' : #Adds a Default Ap to cutsheet + apName = str(apPrefix) + str(formatNumber) + visioGuts () + + elif keyPress == 's': #Adds a Standup Ap to cutsheet + apName = str(apPrefix) + str(formatNumber) + 'S' + visioGuts () + + elif keyPress == 'g' : #Adds a Guard Shack Ap to cutsheet + apName = str(apPrefix) + str(formatNumber) + 'G' + visioGuts () + + elif keyPress == 'm' : #Adds a MOD/KIVA Ap to cutsheet + apName = str(apPrefix) + str(formatNumber) + 'M' + visioGuts () + + elif keyPress == 'h' : #Adds a High Racking Ap to cutsheet + apName = str(apPrefix) + str(formatNumber) + 'H' + visioGuts () + + elif keyPress == 'd' : #Adds a Door Ap to cutsheet + apName = str(apPrefix) + str(formatNumber) + 'D' + visioGuts () + + elif keyPress == 'e' : #Adds a External Ap to cutsheet + apName = str(apPrefix) + str(formatNumber) + 'E' + visioGuts () + + elif keyPress == '[': #goes down one ap number. + apNumber -= 1 + excelStartingInteger -= 1 + formatNumber = format(apNumber, '05') + apName = str(apPrefix) + str(formatNumber) + print (apName + " fix?") + time.sleep(.09) + + elif keyPress == ']': #goes up one ap number. + apNumber += 1 + excelStartingInteger += 1 + formatNumber = format(apNumber, '05') + apName = str(apPrefix) + str(formatNumber) + print (apName + " fix?") + time.sleep(.09) + + elif keyPress == 'pause': #Well it pauses everthing..... + print('Paused') + time.sleep(.3) + pause() #Program is stuck in the pause loop until pause is pressed again + + elif keyPress == '=': #Saves the CAD Cutsheet and ends the Visio Tool + saveExcel() + exit(0) + From 30f85852af8aecaf9487c4de2ca82e500a3357f8 Mon Sep 17 00:00:00 2001 From: airopathfitz <52722008+airopathfitz@users.noreply.github.com> Date: Wed, 24 Jul 2019 09:22:07 -0700 Subject: [PATCH 2/3] Delete ComboScript 5.1.py --- AutoScript/ComboScript 5.1.py | 272 ---------------------------------- 1 file changed, 272 deletions(-) delete mode 100644 AutoScript/ComboScript 5.1.py diff --git a/AutoScript/ComboScript 5.1.py b/AutoScript/ComboScript 5.1.py deleted file mode 100644 index 7584ad3..0000000 --- a/AutoScript/ComboScript 5.1.py +++ /dev/null @@ -1,272 +0,0 @@ -import keyboard, openpyxl, pyautogui, tkinter, time -from tkinter import filedialog, messagebox, Tk -from openpyxl import Workbook, load_workbook - -class Options: - def open_audit_sheet (self): #Opens a file explorer and returns path from chosen file - global audit_sheet - Tk().withdraw() # We don't want a full GUI, so keep the root window from appearing - xlname = filedialog.askopenfilename() # Show an "Open" dialog box and return the path to the selected file - print("Loading Excell File... ") - audit_book = load_workbook(xlname)#Opens Excel - audit_sheet = audit_book['Audit'] #grabs information from the "audit" sheet - - def audit_sheet_sorter (self): #reads all AP's from chosen Audit Sheet and categories them by their color - global AP_red_list - global AP_blue_list - global AP_green_list - global AP_orange_list - - xlname_col = 'A' #column letter to read AP names from - xlname_col_fail = 'K' #column letter to read fails from - xlname_row = int('3') #Starting row in excel - xlname_row_fail = int('3') #Starting row in excel - - AP_red_list = [] #initiates a list for green AP's ('2') - AP_blue_list = [] #initiates a list for green AP's ('4') - AP_green_list = [] #initiates a list for green AP's ('1') - AP_orange_list = [] #initiates a list for green AP's ('3') - - AP_red_count_list = int('0')#Keeps track how long the list is - AP_blue_count_list = int('0') - AP_green_count_list = int('0') - AP_orange_count_list = int('0') - - print("List of Failed AP ID's:") - for AP in range (0,15): #range of APS being colored - xlname_col_fail_num = str(xlname_col_fail) + str(xlname_row_fail) - xlname_col_num = str(xlname_col) + str(xlname_row) - cell_value1 = audit_sheet[xlname_col_fail_num] - cell_value2 = audit_sheet[xlname_col_num] - AP_fail = cell_value1.value - AP_ID = cell_value2.value - - if AP_fail == 1: #reads all green AP's - AP_green_list.append(AP_ID) - print(AP_green_list[AP_green_count_list]) - AP_green_count_list += 1 - - elif AP_fail == 2: #reads all red AP's - AP_red_list.append(AP_ID) - print(AP_red_list[AP_red_count_list]) - AP_red_count_list += 1 - - elif AP_fail == 3: #reads all orange AP's - AP_orange_list.append(AP_ID) - print(AP_orange_list[AP_orange_count_list]) - AP_orange_count_list += 1 - - elif AP_fail == 4: #reads all blue AP's - AP_blue_list.append(AP_ID) - print(AP_blue_list[AP_blue_count_list]) - AP_blue_count_list += 1 - - else: - print('End of Audit Sheets') - break - xlname_row_fail += 1 - xlname_row += 1 - - def search_options (self): #sets visio to search all pages for AP IDs, must be done before coloring - print ("\nStarting Search...") - pyautogui.hotkey('ctrl', 'f') - pyautogui.press(['tab','tab']) - pyautogui.press('down') - pyautogui.press('esc') - - def auto_script_green(self): #finds AP name in Visio and colors it GREEN, - AP_green_count = 0 - for x in AP_green_list: - AP_num = AP_green_list[AP_green_count] - AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. - print(AP_num_print) - pyautogui.hotkey('ctrl', 'f') - pyautogui.typewrite(AP_num_print) - pyautogui.press(['enter', 'esc','esc','tab','enter']) - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('alt', 'h')#line coloring - pyautogui.press(['l','down','down','down','down','down','down','down','left','enter']) - pyautogui.hotkey('alt', 'h')#fill coloring - pyautogui.press(['i','down','down','down','down','down','down','down','left','enter']) - AP_green_count += 1 #adds one to total green count - print(f'Green APs: {AP_green_count}') - - def auto_script_red(self): #finds AP name in Visio and colors it RED, - AP_red_count = 0 - for x in AP_red_list: #finds AP name in Visio and colors it - AP_num = AP_red_list[AP_red_count] - AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. - print(AP_num_print) - pyautogui.hotkey('ctrl', 'f') - pyautogui.typewrite(AP_num_print) - pyautogui.press(['enter', 'esc','esc','tab','enter']) - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('alt', 'h')#line coloring - pyautogui.press(['l','down','down','down','down','down','down','down','left','left','left','left','enter']) - pyautogui.hotkey('alt', 'h')#fill coloring - pyautogui.press(['i','down','down','down','down','down','down','down','left','left','left','left','enter']) - AP_red_count += 1 #adds one to total red count - print(f'Red APs: {AP_red_count}') - - def auto_script_orange(self): #finds AP name in Visio and colors it ORANGE, - AP_orange_count = 0 - for x in AP_orange_list: #finds AP name in Visio and colors it - AP_num = AP_orange_list[AP_orange_count] - AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. - print(AP_num_print) - pyautogui.hotkey('ctrl', 'f') - pyautogui.typewrite(AP_num_print) - pyautogui.press(['enter', 'esc','esc','tab','enter']) - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('alt', 'h')#line coloring - pyautogui.press(['l','down','down','down','down','down','down','down','left','left','left','enter']) - pyautogui.hotkey('alt', 'h')#fill coloring - pyautogui.press(['i','down','down','down','down','down','down','down','left','left','left','enter']) - AP_orange_count += 1 # adds one to total orange count - print(f'Orange APs: {AP_orange_count}') - - def auto_script_blue(self): #finds AP name in Visio and colors it BLUE, - AP_blue_count = 0 - for x in AP_blue_list: - AP_num = AP_blue_list[AP_blue_count] - AP_num_print = (AP_num[8:13]) if len(AP_num) > 5 else AP_num #Truncates site name, IDF, and AP letter. - print(AP_num_print) - pyautogui.hotkey('ctrl', 'f') - pyautogui.typewrite(AP_num_print) - pyautogui.press(['enter', 'esc','esc','tab','enter']) - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('shift','tab','enter') - pyautogui.hotkey('alt', 'h')#line coloring - pyautogui.press(['l','down','down','down','down','down','down','down','right','enter']) - pyautogui.hotkey('alt', 'h')#fill coloring - pyautogui.press(['i','down','down','down','down','down','down','down','right','enter']) - AP_blue_count += 1 #adds one to total blue count - print(f'Blue APs: {AP_blue_count}') - - #def auto_script_total(self): - #print(f'Total APs: ') - #print(f'Total Failed APs:') - def save_new_sheet(self): #Pop-up message box, asks if user wants to save sorted date to new excell file/sheet - result = messagebox.askyesno("Visio AP Coloring Tool","Do you want to save data in new Excell?") - print(result) - if result == True: - print("data saved in 'New File'") - - else: - pass - - -class AutoColor(tkinter.Frame): #POP-UP GUI for choosing majority of Sheets color - def __init__(self, master=None): - super().__init__(master) - self.master = master - - #master = messagebox("Visio AP Coloring Tool\nSelect the AP color majority: ") - self.pack() - self.create_widgets() - - def create_widgets(self): #buttons in the GUI - #self.title.pack(text="""""", justify = Tk.LEFT, padx = 20) - - self.title = tkinter.Label(self, text = "Choose AP Color Majority: ") - self.title.pack(side = "top") - - self.option1 = tkinter.Button(self, fg = "green") #Button, colored green - self.option1["text"] = "Green" #button, named green - self.option1["command"] = self.output1 #when button pressed, execute output1 - self.option1.pack(side="top") #position selt at top most position - - self.option2 = tkinter.Button(self, text = "Red", fg = "red", command = self.output2) #better formatted buttons - self.option2.pack(side="top") - - self.option3 = tkinter.Button(self, text = "Orange", fg = "orange", command = self.output3) - self.option3.pack(side="top") - - self.option4 = tkinter.Button(self, text = "Blue", fg = "blue", command = self.output4) - self.option4.pack(side="top") - - self.quit = tkinter.Button(self, text="QUIT", fg="red", command=self.close) - self.quit.pack(side="bottom", pady = 30) - - def output1(self): #colors all but green - print("GREEN AP Majority...") - print("QUICK! You have 5 seconds to click into your visio file!!!\n") - time.sleep(5) - Options.auto_script_red(self) - Options.auto_script_orange(self) - Options.auto_script_blue(self) - self.close() - - def output2(self): #colors all but red - print("RED AP Majority...") - print("QUICK! You have 5 seconds to click into your visio file!!!\n") - time.sleep(5) - Options.auto_script_green(self) - Options.auto_script_blue(self) - Options.auto_script_orange(self) - self.close() - - def output3(self): #colors all but orange - print("Orange AP Majority...") - print("QUICK! You have 5 seconds to click into your visio file!!!\n") - time.sleep(5) - Options.auto_script_green(self) - Options.auto_script_red(self) - Options.auto_script_blue(self) - self.close() - - def output4(self): #colors all but blue - print("Blue AP Majority...") - print("QUICK! You have 5 seconds to click into your visio file!!!\n") - time.sleep(5) - Options.auto_script_green(self) - Options.auto_script_red(self) - Options.auto_script_orange(self) - Options.save_new_sheet(self) - self.close() - - def close(self): - print("Closing program... Have a nice day :)") - time.sleep(1) - exit(0) - - -def main(): - #choice = "" #creates a blank string for user input - keyPress = "" - #while choice != "3": - while keyPress != "3": - print("Enter '1' to open Visio AP Naming tool") - print("Enter '2' to open Visio AP Coloring tool") - print("Enter '3' to quit program\n") - #choice = input(">>> ") - keyPress = keyboard.read_key() - if keyPress == "1": - import VisioNameTool as vnt - vnt.theGUI() #the GUI function calls these internally: - break #vnt.startWorkbook() - #vnt.openFiles() - #vnt.visioLoop() - #vnt.visioGuts() - #vnt.saveExcel() - elif keyPress == "2": - #AutoColor Tool - start = Options() - start.open_audit_sheet() - start.audit_sheet_sorter() - start.search_options() - root = tkinter.Tk() - A_C = AutoColor(master=root) - A_C.master.title("Visio AP Coloring Tool") - A_C.mainloop() - break - - else: - print("Invalid input") - pass - -if __name__ == "__main__": - main() From 7a386e5e464cb508c9cef7c84a984d962e642cf9 Mon Sep 17 00:00:00 2001 From: airopathfitz <52722008+airopathfitz@users.noreply.github.com> Date: Wed, 24 Jul 2019 09:22:47 -0700 Subject: [PATCH 3/3] Delete VisioNameTool.py --- AutoScript/VisioNameTool.py | 184 ------------------------------------ 1 file changed, 184 deletions(-) delete mode 100644 AutoScript/VisioNameTool.py diff --git a/AutoScript/VisioNameTool.py b/AutoScript/VisioNameTool.py deleted file mode 100644 index 2a8c3f6..0000000 --- a/AutoScript/VisioNameTool.py +++ /dev/null @@ -1,184 +0,0 @@ -import pyautogui, time, openpyxl, keyboard, datetime, sys, os -from openpyxl import Workbook -from tkinter import filedialog, Tk -from guizero import App, Text, TextBox, PushButton, Window - -global siteName -global apPrefix -global apNumber -global apName -global excelCount -global excelNumber -global rowLetter -global rowNumber -global rowWholeName -global list -global excelName -global formatNumber -global excelStartingInteger -global keyPress - -siteName = str ('Paul') -apPrefix = siteName + '-XX-' -apNumber = int('1') -apName = str(apPrefix) + str(apNumber) -excelCount = int('1') -excelNumber = int('1') -rowLetter = 'A' -rowNumber = int('1') - -rowWholeName = str(rowLetter) + str(rowNumber) -list=[99999] -excelName = 'Paul' -formatNumber = format(apNumber, '05') -excelStartingInteger = int('1') -currentTime = datetime.datetime.now().strftime("%Y-%m-%d %H.%M.%S") - -def startWorkbook ():#Starts an excel. Required for visioTool. - global wb - wb = Workbook() - global ws - ws = wb.active - -def openFiles():#Opens file explorer - global excelName - #Tk().withdraw() # We don't want a full GUI, so keep the root window from appearing - excelName = filedialog.askopenfilename() # Show an "Open" dialog box and return the path to the selected file - print(excelName) - print('') - -def pause(): #Pause logic - keyPress = keyboard.read_key() - if keyPress == 'pause': #Reads if pause button has been pressed and unpauses - print('Unpaused') - time.sleep(.3) - exit - else: #If pause has not been pressed then loop repeats infinitely WOO - pause() - -def theGUI(): #all the GUI stuff - print('') - print('Start of Visio Tool') - def apStartingNumber(): # part of GUI that allows changing of the starting AP number - global apNumber - global formatNumber - apNumber = int(startingNumber.value) - formatNumber = format(apNumber, '05') - print ('AP number changed to ' + str(apNumber)) - changingText.value = "AP number changed to " + str(apNumber) #Text for changing AP number - - def changeSiteName(): # part of GUI that allows changing of the site name - global siteName - global apPrefix - global apName - siteName = str(siteNames.value) - apPrefix = siteName + '-XX-' - apName = str(apPrefix) + str(apNumber) - print('Site name changed to ' + siteName) - changingText.value = "Site changed to " + siteName #Text for changing site name - - def directions(): #Once "Go?" has been pressed execute the following items - startWorkbook() - openFiles() - app.hide() - visioLoop() - python = sys.executable #Restarts the whole program - os.execl(python, python, * sys.argv) #Restarts the whole program - - app = App(title = "Phoenix_Oath", width=352, height=132, layout='grid') - - button7 = PushButton(app, text = "Go?", command = directions, grid=[2,3]) - - #Logic for changing starting AP number - startingNumberText = Text(app, text="AP Number?", align="left", grid=[0,1]) #Text asks for AP number - startingNumber = TextBox(app, align="right",text = "1", width=30, grid=[1,1]) #Text box for data entry - button4 = PushButton(app, text = "Confirm", command = apStartingNumber, grid=[2,1]) - - #Logic for changing site name - siteNamesText = Text(app, text="Site Name?", align="left", grid=[0,2]) #Text asks for site name - siteNames = TextBox(app, align="right",text = "PAUL", width=30, grid=[1,2]) #Text box for data entry - button6 = PushButton(app, text = "Confirm", command = changeSiteName, grid=[2,2]) - - changingText = Text(app,text="War has changed", align ="left", grid=[1,3]) - app.display() # initiates the GUI. Allowing it to be used - -def saveExcel(): # saves Visio Tool names to Excel - global displayText - global excelName - wb.save(excelName) # Saves workbook - print ('') - print ('Worksheet saved') - print ('End of Visio Tool') - -def visioGuts(): # the internals to the Visio Tool. Determines how most of the program is run - global apNumber - global formatNumber - global excelStartingInteger - print (apName) - ws.cell(excelStartingInteger, 1, apName) #writes in excel **format** ->(row, column, content to be written in cell) - pyautogui.press('backspace'); pyautogui.typewrite(str(formatNumber)) # takes control of keyboard. hits backspace and types AP number - apNumber += 1 #increments ap number up by 1 - excelStartingInteger += 1 # Increments Excel cell to be written in - formatNumber = format(apNumber, '05') # Modifies apNumber by adding up to 5 zeros in front - -def visioLoop(): - global apNumber - global formatNumber - global excelStartingInteger - global apName - while True: - keyPress = keyboard.read_key() #reads ALL keypress's and saves to variable - - if keyPress == '`' : #Adds a Default Ap to cutsheet - apName = str(apPrefix) + str(formatNumber) - visioGuts () - - elif keyPress == 's': #Adds a Standup Ap to cutsheet - apName = str(apPrefix) + str(formatNumber) + 'S' - visioGuts () - - elif keyPress == 'g' : #Adds a Guard Shack Ap to cutsheet - apName = str(apPrefix) + str(formatNumber) + 'G' - visioGuts () - - elif keyPress == 'm' : #Adds a MOD/KIVA Ap to cutsheet - apName = str(apPrefix) + str(formatNumber) + 'M' - visioGuts () - - elif keyPress == 'h' : #Adds a High Racking Ap to cutsheet - apName = str(apPrefix) + str(formatNumber) + 'H' - visioGuts () - - elif keyPress == 'd' : #Adds a Door Ap to cutsheet - apName = str(apPrefix) + str(formatNumber) + 'D' - visioGuts () - - elif keyPress == 'e' : #Adds a External Ap to cutsheet - apName = str(apPrefix) + str(formatNumber) + 'E' - visioGuts () - - elif keyPress == '[': #goes down one ap number. - apNumber -= 1 - excelStartingInteger -= 1 - formatNumber = format(apNumber, '05') - apName = str(apPrefix) + str(formatNumber) - print (apName + " fix?") - time.sleep(.09) - - elif keyPress == ']': #goes up one ap number. - apNumber += 1 - excelStartingInteger += 1 - formatNumber = format(apNumber, '05') - apName = str(apPrefix) + str(formatNumber) - print (apName + " fix?") - time.sleep(.09) - - elif keyPress == 'pause': #Well it pauses everthing..... - print('Paused') - time.sleep(.3) - pause() #Program is stuck in the pause loop until pause is pressed again - - elif keyPress == '=': #Saves the CAD Cutsheet and ends the Visio Tool - saveExcel() - exit(0) -