HotKeySet ("^c", "SC_Exit_1") AutoItSetOption ("SendKeyDelay", 50) #include #include #include #include #include #include #include #include #include Opt("WinTitleMatchMode", 1) Global $var = "C:\Users\Public\MT Script\PC_Names.xlsx" Global $oExcel_A2 = _Excel_Open() Global $oWorkBook = _Excel_BookOpen($oExcel_A2, $var) Global $ExcelRead_A2 = _Excel_RangeRead ($oWorkBook, 1, "A2") Global $ExcelRead_B2 = _Excel_RangeRead ($oWorkBook, 1, "B2") StartGUI() Func StartGUI() #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Created By: ", 323, 208, -1, -1) Global $Label_1 = GUICtrlCreateLabel("Computer Name", 64, 24, 80, 17) ;Global $Input_1 = GUICtrlCreateInput("", 160, 24, 121, 21) Global $Input_1 = GUICtrlCreateInput($ExcelRead_A2, 160, 24, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) Global $Label_2 = GUICtrlCreateLabel("Computer Description", 40, 56, 105, 17) ;Global $Input_2 = GUICtrlCreateInput("", 160, 56, 121, 21) Global $Input_2 = GUICtrlCreateInput($ExcelRead_B2, 160, 56, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;Global $Group_1 = GUICtrlCreateGroup("Mnemonic", 40, 80, 241, 73) Global $Label_3 = GUICtrlCreateLabel(" Location:", 96, 96, 51, 17) Global $Radio_1 = GUICtrlCreateRadio("Fort Worth", 160, 96, 113, 17) Global $Radio_2 = GUICtrlCreateRadio("Dallas", 160, 120, 113, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Submit = GUICtrlCreateButton("Submit", 112, 160, 75, 25) ;$Clear = GUICtrlCreateButton("Clear", 208, 160, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Submit Global $DataFromUser_1 = GUICtrlRead ($Input_1) Global $DataFromUser_2 = GUICtrlRead ($Input_2) If GUICtrlRead($Radio_1) = 1 Then Global $DataFromUser_3 = "DAL SITE" If GUICtrlRead($Radio_2) = 1 Then Global $DataFromUser_3 = "GSW SITE" If $DataFromUser_3 = "GSW SITE" = 1 Then Global $Facility = "FORT WORTH" If $DataFromUser_3 = "DAL SITE" = 1 Then Global $Facility = "DALLAS" Global $SaveLocation = ("C:\Users\Public\MT Script\PC_Log.txt") GUIDelete() ;StartMT_A2() PC_Log_A2() ;Case $Clear ;GUICtrlSetData($Input_1, '') ;GUICtrlSetData($Input_2, '') EndSwitch WEnd EndFunc ;----------------------------------------------------------- ; *** APP INTERACTION *** (REPEATS BELOW) ;----------------------------------------------------------- Func StartMT_A2() WinActivate ("GCR") Sleep (2000) Send ($DataFromUser_1) ;In the copies, I replace this with "$ExcelRead_A3" or "$ExcelRead_A4", etc. Sleep (1000) Send ("{ENTER}") Sleep (2000) Send ("Y") Sleep (1000) Send ("{ENTER 2}") Sleep (1000) Send ($DataFromUser_2) ;In the copies, I replace this with "$ExcelRead_B3" or "$ExcelRead_B4", etc. Sleep (1000) Send ("{ENTER}") Sleep (1000) Send ("SUMMER 24") Sleep (1000) Send ("{ENTER 7}") Sleep (1000) Send ("Y") Sleep (1000) Send ("{ENTER 2}") Sleep (1000) Send ("Y") Sleep (1000) Send ("{ENTER}") Sleep (1000) Send ($DataFromUser_3) Sleep (1000) Send ("{ENTER}") Sleep (1000) Send ("DFW METROPLEX") Sleep (1000) Send ("{ENTER}") Sleep (1000) Send ("LOGIN") Sleep (1000) Send ("{ENTER 2}") Sleep (1000) Send ("Y") Sleep (1000) Send ("{ENTER}") Sleep (1000) Send ("2") Sleep (1000) Send ("{ENTER 2}") PC_Log_A2() EndFunc ;----------------------------------------------------------- ; *** SAVE FILE DATA *** ;----------------------------------------------------------- Func PC_Log_A2() FileWrite($SaveLocation, $DataFromUser_1) FileWrite($SaveLocation, ', ') FileWrite($SaveLocation, $Facility) FileWrite($SaveLocation, ', ') FileWrite($SaveLocation, $DataFromUser_3) FileWrite($SaveLocation, @CRLF) StartMT_A3() EndFunc ;----------------------------------------------------------- ; *** THIS SECTION PROVIDES THE NEW EXCEL CELL LOCATIONS. *** ;----------------------------------------------------------- Func StartMT_A3() Global $ExcelRead_A3 = _Excel_RangeRead ($oWorkBook, 1, "A3") Global $ExcelRead_B3 = _Excel_RangeRead ($oWorkBook, 1, "B3") ;----------------------------------------------------------- ; *** NOTE *** (THIS SECTION WOULD REPEAT THE "StartMT_A2" ; APP INTERACTION FUNCTION, UNDER A DIFFERERENT NAME.) ; OMITTED HERE TO KEEP THE SCRIPT SHORTER. ;----------------------------------------------------------- PC_Log_A3() EndFunc ;----------------------------------------------------------- ; *** NOTE *** (THIS REPEATS THE "PC_LOG" FUNCTION, UNDER ; A DIFFERERENT NAME.) ;----------------------------------------------------------- Func PC_Log_A3() FileWrite($SaveLocation, $ExcelRead_A3) FileWrite($SaveLocation, ', ') FileWrite($SaveLocation, $Facility) FileWrite($SaveLocation, ', ') FileWrite($SaveLocation, $DataFromUser_3) FileWrite($SaveLocation, @CRLF) StartMT_A4() EndFunc ;----------------------------------------------------------- ; *** THIS SECTION PROVIDES THE NEW EXCEL CELL LOCATIONS. *** ;----------------------------------------------------------- Func StartMT_A4() Global $ExcelRead_A4 = _Excel_RangeRead ($oWorkBook, 1, "A4") Global $ExcelRead_B4 = _Excel_RangeRead ($oWorkBook, 1, "B4") ;----------------------------------------------------------- ; *** NOTE *** (THIS SECTION WOULD REPEAT THE "StartMT_A2" ; APP INTERACTION FUNCTION, UNDER A DIFFERERENT NAME.) ; OMITTED HERE TO KEEP THE SCRIPT SHORTER. ;----------------------------------------------------------- PC_Log_A4() EndFunc ;----------------------------------------------------------- ; *** NOTE *** (THIS REPEATS THE "PC_LOG" FUNCTION, UNDER ; A DIFFERERENT NAME.) ;----------------------------------------------------------- Func PC_Log_A4() FileWrite($SaveLocation, $ExcelRead_A4) FileWrite($SaveLocation, ', ') FileWrite($SaveLocation, $Facility) FileWrite($SaveLocation, ', ') FileWrite($SaveLocation, $DataFromUser_3) FileWrite($SaveLocation, @CRLF) EXIT EndFunc ;----------------------------------------------------------- ; *** EMERGENCY EXIT MESSAGE *** ;----------------------------------------------------------- Func SC_Exit_1() MsgBox (16, "Force Quit", "The script has been CTRL+C terminated.") Exit EndFunc