slybry70 Posted February 3, 2021 Share Posted February 3, 2021 Thank you for your time first of all. The code I am working on is to remove all information of a computer on a specific application for either a single pc name or multiple PC names. I have the code working with copy and pasting of a single pc name but now I want to add the function that will allow hopefully the copy and pasting of multiple strings either from excel into an array and run through the list until all are removed from that application. I would like to copy from excel or text file and into a gui window that will take the input and create the array then create a the list and go down the list showing as they are removed until you reach the end. This has been problematic. I cannot find any info online about copying a group of strings then pasting into a Autoit Window and having it create the array with that input. Does this sound familiar with anyone? I could just copy that info into an excel file and input into the array from there but that wouldn't be as graceful and would take more time and steps then a simple copy data then paste into window and create array. I can put the code I do have in the ticket but the new function doesn't have much to do with the code in the rest of the program just yell if you need it. Thank you! Link to comment Share on other sites More sharing options...
Nine Posted February 3, 2021 Share Posted February 3, 2021 Yes it would help if you could provide a snippet of the code you have problem with. If you could also upload the excel or text file so we know what you are after... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
slybry70 Posted February 3, 2021 Author Share Posted February 3, 2021 expandcollapse popup; Computer LWS Decommission Script #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <Constants.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <Excel.au3> #include <File.au3> #include <Misc.au3> #include <FileConstants.au3> #include <Array.au3> #include <ProgressConstants.au3> #include <ColorConstants.au3> #include <WinApi.au3> #include <IE.au3> Global $EnterPCNames, $ReadExcelNames, $ManuallyChecked, $ExcelReadChecked Opt("TrayAutoPause", 0) Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL, $MB_TOPMOST), "SLHS Computer Removal", "This is the SLHS Computer Removal script Hit Yes to Continue. Hit No if you do not wish to run this script.") MsgBox(BitOR($MB_OK, $MB_SYSTEMMODAL, $MB_TOPMOST), "Make sure Text is set to LWS main Menu.", "Hit Ok once Text is set to LWS and its left on the main Menu.") ;***************************************************************************************************** ;----------------Map T drive if its not Mapped------------------------------ Might not need this and can take out later on. If $iAnswer = 7 Then MsgBox($MB_SYSTEMMODAL, "AutoIt", "Exiting script.") Exit EndIf DriveMapGet("T:") If @error = 1 Then ;msgbox(0,"result", "NOT MAPPED") DriveMapAdd("T:", "\\fs1cle\tech") Else ;msgbox(0,"result", "MAPPED") EndIf ;***************************************************************************************************** ; Initial GUI Setup Global $aTaskbarinit = WinGetPos("[CLASS:Shell_TrayWnd]", "") $Window = GUICreate("Choose the method of entering the PC names:", 440, 100, @DesktopWidth, @DesktopHeight) WinSetOnTop("Choose the method of entering the PC names:", "", 1) Global $aWinInitGui = WinGetPos($Window) $EnterPCNames = GUICtrlCreateCheckbox("Enter PC Names in Manually.", 8, 8, 160, 17) $ReadExcelNames = GUICtrlCreateCheckbox("Read all names from an Excel File.", 8, 32, 180, 17) ;41,17 Global $GUIContinueButton = GUICtrlCreateButton("Continue", 8, 65, 75, 25, $WS_GROUP) ; Move the Initial GUI to the bottom right WinMove($Window, "", @DesktopWidth - $aWinInitGui[2] - 4, @DesktopHeight - $aWinInitGui[3] - $aTaskbarinit[3] - 4) GUISetState(@SW_SHOW) Sleep(2000) ;---------------------------------------------------------------------------------------------------------------------------- ;-------------------Is checked for each box0------------ $ManuallyChecked = GUICtrlRead($EnterPCNames) $ExcelReadChecked = GUICtrlRead($ReadExcelNames) ;Global $CurrUser = StringMid("Currently logged in User: " & _GetConsoleUser(), 31, 6) ; Find out which ones were checked and pull out the name of the Printer. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUIContinueButton If GUICtrlRead($EnterPCNames) = $GUI_CHECKED Then ;GUICtrlSetData($ManuallyChecked, 'Checked') ManualEntryFunc() Sleep(2000) Else GUICtrlSetData($EnterPCNames, 'Unchecked') EndIf If GUICtrlRead($ReadExcelNames) = $GUI_CHECKED Then ;GUICtrlSetData($EpicChecked, 'Checked') ExcelEntriesFunc() Sleep(2000) Else GUICtrlSetData($ReadExcelNames, 'Unchecked') EndIf ExitLoop EndSwitch WEnd GUISetState(@SW_ENABLE) GUIDelete($Window) Func ManualEntryFunc() Local $PCname, $PCNameLabel, $PCNameInput, $PCNameView, $GUIContinueButton, $iAnswer, $RNDM, $AVNumber ; Remove the initial Window. GUISetState(@SW_ENABLE) GUIDelete($Window) ;Create the Window to enter the single computer name------------------------------------------------ ; Initial GUI Setup Global $aTaskbarinit = WinGetPos("[CLASS:Shell_TrayWnd]", "") $SinglePCGUI = GUICreate("PC Name to Decommission LWS", 440, 100, @DesktopWidth, @DesktopHeight) WinSetOnTop("Please enter the Computer name to Decommission:", "", 1) Global $aWinInitGui = WinGetPos($SinglePCGUI) ;$EnterPCNames = GUICtrlCreateCheckbox("Enter PC Names in Manually.", 8, 8, 160,17) Local $PCNameLabel = GUICtrlCreateLabel("Enter PC name being removed: ", 8, 15, 165, 20) Local $PCNameInput = GUICtrlCreateInput("", 175, 15, 100, 20) ; 80,20 Local $GUIContinueButton = GUICtrlCreateButton("Continue", 8, 65, 75, 25, $WS_GROUP) ; Move the Initial GUI to the bottom right WinMove($SinglePCGUI, "", @DesktopWidth - $aWinInitGui[2] - 4, @DesktopHeight - $aWinInitGui[3] - $aTaskbarinit[3] - 4) GUISetState(@SW_SHOW) Sleep(2000) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUIContinueButton If GUICtrlRead($PCNameInput) = "" Then Local $PCNameLabel = GUICtrlCreateLabel("No computer name entered. ", 8, 35, 165, 20) Sleep(5000) ManualEntryFunc() Else $PCNameView = GUICtrlRead($PCNameInput) WinActivate("You are connected to Epic ""PROD"" Environment", "") ; Activate the Chronicles window Sleep(2000) WinSetState("You are connected to Epic ""PROD"" Environment", "", @SW_ENABLE) Send("{ENTER}" & "{ENTER}" & "11" & "{ENTER}" & "LWS" & "{ENTER}" & "1") Sleep(2000) Send("{ENTER}" & "1" & "{ENTER}" & "1" & "{ENTER}") ; Should be at the Workstation LWS prompt at this time. Now Remove all Entries. ;------------------------------------------------------------------------------------------------------------------------------------- Sleep(2000) Send($PCNameView & "{ENTER}") ;------------Find out if the computer name has an LWS or not and remove it if it does. Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL, $MB_TOPMOST), "LWS Exists?", "Does this computer have an lws. (Yes/No)") If $iAnswer = 7 Then ; No Answer MsgBox($MB_SYSTEMMODAL, "PC Decommission", "There is no LWS for this PC name.") Sleep(5000) Exit Else ;Yes Answer Send("{home down}" & "{F9}" & sleep(1000) & "{home up}" & "i") Send("{ENTER}" & "52216" & "{ENTER}" & "100000" & "{ENTER}") ;Set 100000-SLHS COMBINATION FDI sleep(2000) Send("{PGUP 7}" & "{ENTER}" & "{F1}") ;Set Exam room workstation: sleep(2000) Send("{PGUP 2}" & "{F1}" & "{ENTER 2}" & "{F1 20}") ;Set Default OTG to Empty and same with additional departments sleep(2000) Send("{PGUP 5}" & "{F1 5}" & "{ENTER 2}" & "{F1 60}") ; Remove all print groups and classifications. Sleep(4000) Send("{PGUP 10}" & "{F1}" & "{ENTER}" & "{DOWN 2}" & "{TAB}" & "No") ; Remove setting for epic hyperspace timeout sleep(4000) Send("{PGUP}" & "{F1}" & "{ENTER}" & "{F1}" & "{ENTER}") ;Remove Department and Profile Department sleep(2000) send("{PGUP}" & "{DOWN 3}" & "{F1}" & "Inactive" & "{ENTER}") ; Generate random number between 1000 and 80000 then ad the AV to front and ask user if there was an error and if so then regenerate and retry. ; This area will create a random number, See if that AV###### has an lws and then verify if it exists. If it does exist ;then it will create another one and look again. Local $AVTaken = "yes" While $AVTaken == "yes" $RNDM = Random(1000, 800000, 1) ; Return an integer between 5 and 20 to determine the length of the string. Local $AVNumber = ("AV" & $RNDM) Send("{UP 2}" & "{F1}" & $AVNumber & "{ENTER}") Sleep(2000) Local $AVAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL, $MB_TOPMOST), "LWS Exists for AV###?", "Is there an lws already for this AV###? (Yes/No)") if $AVAnswer == "7" Then sleep(2000) Send("{UP 3}" & "{F1}" & $AVNumber & "{ENTER}") $AVTaken = "no" Sleep(2000) Exit EndIf sleep(2000) WEnd EndIf EndIf EndSwitch WEnd EndFunc ;==>ManualEntryFunc ;----------------Multiple PC name sheet entries----------------------- Func ExcelEntriesFunc() EndFunc ;==>ExcelEntriesFunc ;ExcelEntriesFunc() ComputerDecomm.au3 Link to comment Share on other sites More sharing options...
slybry70 Posted February 3, 2021 Author Share Posted February 3, 2021 The script is working for a single pc name to remove from the specific application. Now working on the function at the bottom that is listed as ExcelEntriesFunc() Link to comment Share on other sites More sharing options...
slybry70 Posted February 3, 2021 Author Share Posted February 3, 2021 As I stated earlier what I would like to do in the function ExcelEntriesFunc() is this. I would like to copy from excel or text file and into a GUI window that will take the input and create the array, Show a GUI with that list and go down the list showing as they are removed until you reach the end. This has been problematic. I cannot find any info online about copying a group of strings then pasting into a Autoit Window and having it create the array with that input. Does this sound familiar with anyone? I am sure that I could get it working if I copied all the computer names into a excel file then read all those names from that excel file and show them into a GUI and go through that list while removing each but this would not be as efficient as copying all the computer names into a autoit Window which would be faster and more efficient. Not sure how good I am describing what I am needing..... Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 3, 2021 Share Posted February 3, 2021 @slybry70 Take a closer look to Excel UDF to read the data from Excel to an array (and much more) and ListView Control to show the data copied from Excel Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
slybry70 Posted February 3, 2021 Author Share Posted February 3, 2021 Thank you. I have used Excel UDF but thank you for the information on GUICtrlCreateListView. Looks like it could do mostly what I had in mind 🙂 Thank you for your time! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now