Jump to content

Jibsbrown

Members
  • Posts

    14
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Jibsbrown's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thank you all for the help with this. Was immense help with learning AutoIT.
  2. Hello, Having a headache get powershell get-printer to store in an array. tried a few different ways but either get a black array or error. the following I at least get a value in array but not getting the printer list. any ideas to get the results to show in to an array? ;#RequireAdmin #include <Constants.au3> #include <Array.au3> $aPntList = Run("powershell.exe get-printer" , @SystemDir , @SW_HIDE) $PrtList = StringSplit ($aPntList, @CRLF, 2) _ArrayDisplay ($PrtList)
  3. Sorry for taking longer then 48 hours to reply, but this has lead to a rabbit hole of coding challenges. Jos's: I was able to fix the my problems with FileOpen() but still had to rewrite to get iniwritesection to get script to fully write the ini file correctly. ...after looking and working with Subz's post (it cut my code lines by 20). And with Subz pointing out that... _ArrayColDelete($aUpdates, 1) existed... very easy solution for displaying only one column for an array in list view. it saved me from trying to figure out how to work one of Zedna's solutions (which provided a 20 day Autoit Noob so many challenges) into the work project. Thank you both for the help and will post the end results in a few days for your review... if this post is still open but if not, will post when scripted complete. Thanks for the help and pointers.
  4. Just wanted to thank Jos and Subz. You both provided me some work to do... will update in 48 hours with what I find from both posts.
  5. Thank you Jos for the correction, but even without FileOpen($fUpsList) IniWriteSection($fUpsList, "InstallOrder", "") FileClose($fUpsList) Still getting the same result and the above was a stab at thinking I did not know what I was doing (which I'm positive of since I'm a 90 day Autoit Noob). So with a little playing around I did get the file path to write but its showing up in a file titled "1" without an extension. With the following line added... $ActiveFile = FileOpen($fUpsList, $FO_APPEND) IniWriteSection($ActiveFile, "Path", $upsPath) Without these lines still getting the same results without the FileOpen() / FileClose. The $path is written but the loop overwrites the ini file and only records the LV afte the submit button is pressed. #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; *** End added by AutoIt3Wrapper *** #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <ListViewConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIListViewEx.au3> ;User choses folder path Global $Path = FileSelectFolder("Select Upadates Folder", @ScriptDir) $upsPath = $Path ;MsgBox(0, "", $Path, 5) $fUpsList = @ScriptDir & "\InstallList.ini" ;$ActiveFile = FileOpen($fUpsList, $FO_APPEND) IniWriteSection($fUpsList, "Path", $upsPath) Global $aUpdates = _FileListToArrayRec($Path, "*.*", $FLTAR_FILES) ; All files in folder loaded into array for LV $sFileCount = $aUpdates[0] ; Use file count for error checking - not added yet 3/29 ConsoleWrite($sFileCount & @CRLF) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 482, -1, -1) $Group1 = GUICtrlCreateGroup("Group1", 40, 24, 400, 377) $List1 = GUICtrlCreateListView("Update Files", 48, 72, 385, 305) _GUICtrlListView_SetColumnWidth($List1, 0, 385) $Submit = GUICtrlCreateButton("Submit", 400, 424, 75, 25) $Exit = GUICtrlCreateButton("Exit", 504, 424, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 To UBound($aUpdates) - 1 GUICtrlCreateListViewItem($aUpdates[$i], $List1) Next GUISetState() $lUps = _GUIListViewEx_Init($List1, $aUpdates, 0, 0, True) _GUIListViewEx_MsgRegister() While 1 $vRet = _GUIListViewEx_EventMonitor() ; Reread GLVEx Help doc If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Switch @extended Case 0 Case 4 EndSwitch $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Submit $aContent = _GUIListViewEx_ReturnArray($lUps) _FileWriteFromArray($fUpsList, $aContent) ;this $error check returns 5 - Start index is greater than the $iUbound parameter ;So if the list is empty, it returns error 5 If @error = 5 Then IniWriteSection($fUpsList, "InstallOrder", "") EndIf Exit Case $Exit Exit EndSwitch ;FileClose($fUpsList) WEnd And side note... Currently using Autoit Ver 3.3.14.5 and the "Remarks" for don't mention what you posted about "Remarks". But fairly sure I'm not putting "1+1" together correctly.
  6. Hope someone can find what I've done wrong, because I have no idea. I'm sure its very simple fix. Currently after selecting the folder for files the Listview the path is recorded in the INI file this which works. After submitting the ListView changes with the loop the INI file is over written and the file section name is not being written. Any idea or examples for the solution? Forma searches and help file have not provided the answer(s). Or I'm just not seeing my mistake, which I'm sure is the real problem. #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; *** End added by AutoIt3Wrapper *** #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <ListViewConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIListViewEx.au3> ;User choses folder path Global $Path = FileSelectFolder("Select Upadates Folder", @ScriptDir) $upsPath = $Path ;MsgBox(0, "", $Path, 5) $fUpsList = "InstallList.ini" FileOpen($fUpsList) IniWriteSection($fUpsList, "Path", $Path) FileClose($fUpsList) Global $aUpdates = _FileListToArrayRec($Path, "*.*", $FLTAR_FILES) ; All files in folder loaded into array for LV $sFileCount = $aUpdates[0] ; Use file count for error checking - not added yet 3/29 ConsoleWrite($sFileCount & @CRLF) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 482, -1, -1) $Group1 = GUICtrlCreateGroup("Group1", 40, 24, 400, 377) $List1 = GUICtrlCreateListView("Update Files", 48, 72, 385, 305) _GUICtrlListView_SetColumnWidth($List1, 0, 385) $Submit = GUICtrlCreateButton("Submit", 400, 424, 75, 25) $Exit = GUICtrlCreateButton("Exit", 504, 424, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### For $i = 1 To UBound($aUpdates) - 1 GUICtrlCreateListViewItem($aUpdates[$i], $List1) Next GUISetState() $lUps = _GUIListViewEx_Init($List1, $aUpdates, 0, 0, True) _GUIListViewEx_MsgRegister() While 1 $vRet = _GUIListViewEx_EventMonitor() ; Reread GLVEx Help doc If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error) EndIf Switch @extended Case 0 Case 4 EndSwitch $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Submit $aContent = _GUIListViewEx_ReturnArray($lUps) _FileWriteFromArray($fUpsList, $aContent) ;this $error check returns 5 - Start index is greater than the $iUbound parameter ;So if the list is empty, it returns error 5 If @error = 5 Then FileOpen($fUpsList) IniWriteSection($fUpsList, "InstallOrder", "") FileClose($fUpsList) EndIf Exit Case $Exit Exit EndSwitch WEnd
  7. Thank you again Zedna for the code, see I still have a lot left to learn and figure out. Because I tried using variation of Global $ip[1] with the only success be an error message. Well also on to Func / EndFunc learning as well. Again i can't express my appreciation enough for code help and insights shared. Thank you.
  8. Thank you for the additional info. I tried to get it down to a 1D but due to way I first set the INI with changing keys names I kinda stuck my self a 2D... Or at least that's my 21+ day Autoit brain is telling me. Starting to think that I either leave the key blank or make it the same, but leaning to making this just variables that are made when the EXE starts. But have yet to understand how to get the IPs for the following code to set as global varibles out side of the For/Nest that can later be called for either a direct pass or a clipboard pass to active window input field. ; Get IP and separate into Subnet and host oct $oct = StringSplit(@IPAddress1, ".") $readOct = $oct[4] Global $siteSubnet = $oct[1] & "." & $oct[2] & "." & $oct[3] & "." Global $oHost = $oct[4] ;-Scan Subnet for ping able IPs and get WMIC Data For $i = 50 To 43 Step - 1 $activeIP = Ping($siteSubnet & $i, 250) $PrinterIP = $siteSubnet & $i If @error = 0 Then ;MsgBox(0,"",$PrinterIP,10) ;IniWrite($sInstallIniName, "PrinterIp", $i, $PrinterIP) EndIf Next What I'm building is for a desktop refresh project that will happen at different locations with changing subnets. This part take care of finding the printer IPs.
  9. Thank you very much Zedna, I can now see I had a lot more coding to do to just have one Column. Now its time to read up on DllStructSetData and all that links off. Again thank you.
  10. So trying to get an INI section in a listView with checkboxes. Was able to get the the section values to show until i add the checkboxes and now only the keys are show up. Between reading the Help file, Forum Topic and trying other code option. I have been unable to answer this problem. I'm assuming its something very basic I'm overlooking since this it's day 21 of learning Autoit. If someone could please advise I would appreciate the assistance. Here's the code: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GUIListView.au3> #include <Array.au3> #include <File.au3> #include <ListViewConstants.au3> Global $sIniPath = "installLog.ini" ;ConsoleWrite($sIniPath) $iniSctionNames = IniReadSectionNames($sIniPath) ;_ArrayDisplay($iniSctionNames, "$iniSctionNames") $keys2 = IniReadSection($sIniPath, $iniSctionNames[2]) _ArrayDisplay($keys2 , "$keys2") ; Create GUI $hGUI = GUICreate("Test", 300, 250) ; Create ListView $cLV = GUICtrlCreateListView("", 10, 10, 200, 200,$LVS_List,$LVS_EX_CHECKBOXES) _GUICtrlListView_AddColumn($cLV, $keys2, 100) _GUICtrlListView_AddColumn($cLV, $keys2, 100) ;_GUICtrlListView_AddItem($cLV, $keys2, 0) _GUICtrlListView_AddArray($cLV, $keys2) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd And the INI file I'm using. [OldSysInfo] 4=192.168.0.4|DESKTOP-RDIU2SN|R90M05Q8 5=192.168.0.5|SD0123456789101|R9WGP9P 6=192.168.0.6|SD0123456789102|R9WGP9PT 3=192.168.0.3|DESKTOP-3RS4LKL|R9WGP9P 23=192.168.0.23|SD0123456789102|MXL1234P5I [PrinterIp] 50=192.168.0.50 48=192.168.0.48 47=192.168.0.47 [NewSysInfo] newPC = SD0123456789adfs|192.168.0.185|2UA1234FTR Also if possible could you explain how to hide the Array count row as well.
  11. Not sure this topic is still open and after looking at code thinking I should move this to GUI.
  12. Don't know if I can add to this topic or not. So if I'm wrong please advise proper etiquette. Need to ask for some additional understanding. What have I gotten wrong with the below code? ArrayDisplays shows that $keys2 has data and ConsoleWrite write the correct text, but the ListView is blank. Still using the same Ini file posted at the top of the topic. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GUIListView.au3> #include <Array.au3> #include <File.au3> Global $sIniPath = "installLog.ini" ;ConsoleWrite($sIniPath) $iniSctionNames = IniReadSectionNames($sIniPath) ;_ArrayDisplay($iniSctionNames, "$iniSctionNames") $keys2 = IniReadSection($sIniPath, $iniSctionNames[2]) _ArrayDisplay($keys2 , "$keys2") ; Create GUI $hGUI = GUICreate("Test", 600, 500) ; Create ListView $cLV = GUICtrlCreateListView("", 10, 10, 580, 300) For $i = 1 To UBound($keys2) - 1 ConsoleWrite($keys2[$i][1] & @CRLF) _GUICtrlListView_AddArray($cLV, $keys2[$i][0]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd And I did try it with GUICtrlListView_AddArray($cLV, $Keys2[$i][1]) with the same result.
  13. Thank you Water and Chimp, the logic check helped. Realize now that what I wanted to do was this... Global $sIniPath = "installLog.ini" ;ConsoleWrite($sIniPath) $iniSctionNames = IniReadSectionNames($sIniPath) ; _ArrayDisplay($iniSctionNames, "$iniSctionNames") $keys1 = IniReadSection($sIniPath, $iniSctionNames[1]) $keys2 = IniReadSection($sIniPath, $iniSctionNames[2]) $keys3 = IniReadSection($sIniPath, $iniSctionNames[3]) ;_ArrayDisplay($keys1, "$keys") ConsoleWrite($keys1[1][1]) And Chimp thank you for code below.. ;_ArrayDisplay($keys1, "$keys") Just could not get my brain to understand what the Help file was talking about. Let alone make it do anything.
  14. Need some help understanding why the ConsoleWrite works inside 2nd For loop but not out side. Between Audit Wiki, Help file , Forum searching (lots of code reading), and YouTube ( shout out to TutsTeach), I have not been able to find the reason why. $sIniPath = "installLog.ini" ; - Get section name $iniSctionNames = IniReadSectionNames($sIniPath) ; - Get Keys and Vaules For $a = 1 to UBound($iniSctionNames) - 1 $keys = IniReadSection($sIniPath , $iniSctionNames[$a]) For $b = 1 to UBound($keys) - 1 $oldSysInfo = IniRead($sIniPath , $iniSctionNames[1], $keys[$b][0], "") $PntIPInfo = IniRead($sIniPath , $iniSctionNames[2], $keys[$b][0], "") $NewPCInfor = IniRead($sIniPath , $iniSctionNames[3], $keys[$b][0], "") ;ConsoleWrite($oldSysInfo & @LF) Next ;ConsoleWrite($oldSysInfo & @LF) Next ConsoleWrite($oldSysInfo) My intention is to use the variables later for Listboxes. Any explanation, forum post links or whatever would help. Sorry also very very new to Autoit. Also here's the ini file. [OldSysInfo] 4=192.168.0.4|DESKTOP-RDIU2SN|R90M05Q8 5=192.168.0.5|SD0123456789101|R9WGP9P 6=192.168.0.6|SD0123456789102|R9WGP9PT 3=192.168.0.3|DESKTOP-3RS4LKL|R9WGP9P 23=192.168.0.23|SD0123456789102|MXL1234P5I [PrinterIp] 50=192.168.0.50 48=192.168.0.48 47=192.168.0.47 [NewSysInfo] newPC = SD0123456789adfs|192.168.0.185|2UA1234FTR Thank you for your time.
×
×
  • Create New...