Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/31/2018 in all areas

  1. You could also just read the entire first file into an array, then convert to string and output: #include <file.au3> Local $aPCs = FileReadToArray(@DesktopDir & "\UserMachines.txt") Local $sString For $sServer In $aPCs $sString &= '"' & $sServer & '", ' Next FileWrite(@DesktopDir & "\newfile.txt", StringTrimRight($sString, 2)) My text file has LC-PC001 - 020, so output file would look like this:
    2 points
  2. behdadsoft, This is your code with some comments: #RequireAdmin #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <File.au3> local Const $Path = @ScriptDir Dim $Parent[3] Dim $Child[2] local $Count = 0 ;Create GUI local $GUI = GUICreate("TreeView") GUISetState(@SW_SHOW) ; Create InputBox local $Input = GUICtrlCreateInput("",100,25) ; local $InputText = GUICtrlRead($Input,1) ;Read InputBox Text ; Makes no sense at this point in code ; Crete TreeViewObject local $TreeObject = GUICtrlCreateTreeView(100,70,200,250) ;Create Tree Parent for $i = 0 to UBound($Parent) - 1 $Parent[$i] = GUICtrlCreateTreeViewItem("Parent " & $i, $TreeObject) ;Add Child to Parents for $j = 0 to UBound($Child) - 1 ; This loop owerwrites previous items as you can see with _ArrayDisplay $Child[$j] = GUICtrlCreateTreeViewItem("Child " & $Count, $Parent[$i]) ; Returns item control ID, not item text $Count += 1 Next _ArrayDisplay( $Child, "$Child" ) Next while 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop ; Search in InputBox ;Case $InputText Case $Input $InputText = GUICtrlRead($Input) if $InputText <> "" Then MsgBox(0,"",$InputText) for $i = 0 to UBound($Child) - 1 if StringInStr($Child[$i], $InputText) <> 0 Then ; $Child contains item control IDs, makes no sense in this context ;Show only Current shild and parent that are equal with InputText Else ;Show all Parent and child EndIf Next EndIf EndSwitch WEnd GUIDelete($GUI) Then you can continue working with this code: #RequireAdmin #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <Array.au3> #include <File.au3> local Const $Path = @ScriptDir Dim $Parent[3] Dim $Child[6] local $Count = 0 ;Create GUI local $GUI = GUICreate("TreeView") GUISetState(@SW_SHOW) ; Create InputBox local $Input = GUICtrlCreateInput("",100,25) ; Crete TreeViewObject local $TreeObject = GUICtrlCreateTreeView(100,70,200,250) ;Create Tree Parent for $i = 0 to UBound($Parent) - 1 $Parent[$i] = GUICtrlCreateTreeViewItem("Parent " & $i, $TreeObject) ;Add Child to Parents for $j = 0 to 1 $Child[$Count] = GUICtrlCreateTreeViewItem("Child " & $Count, $Parent[$i]) $Count += 1 Next _ArrayDisplay( $Child, "$Child" ) Next while 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop ; Search in InputBox ; Search for 1 - 6 Case $Input $InputText = GUICtrlRead($Input) if $InputText <> "" Then MsgBox(0,"",$InputText) for $i = 0 to UBound($Child) - 1 if StringInStr(GUICtrlRead($Child[$i],1), $InputText) <> 0 Then MsgBox(0,"",GUICtrlRead($Child[$i],1)) ;Show only Current shild and parent that are equal with InputText Else ;Show all Parent and child EndIf Next EndIf EndSwitch WEnd GUIDelete($GUI) Add a new post if you have any doubts.
    1 point
  3. Just curious to see if any one else has run into this issue. When creating list of index, to insert items at in _ArrayInsert, all the indexes have to be the same number of digits or i.t fails with @error = 3 If you set the range to 3;5;7 it works, if its set to 10,15,17 it works, if you set it to 3;15;17 fails if you set it to 03,15,17 it works. Here is an example that shows this. ; have the same issues when running on ; AutoIT Version 3.3.14.5 ; AutoIT Beta Version 3.3.15.0 #include <Array.au3> Local $aTest[151]=[] For $i = 0 To 150 $aTest[$i] = 'Line_' & $i Next ; this works - @error = 0 Local $sIdx = '3;5;7;9' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 1', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '13;15;17;19' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 2', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this does not work - @error = 3 $sIdx = '3;5;17;19' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 3', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '03;05;17;19' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 4', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this does not work - @error = 3 $sIdx = '13;15;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 5', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '013;015;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 6', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this does not work - @error = 3 $sIdx = '3;15;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 7', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx) ; this works - @error = 0 $sIdx = '003;015;107;109' _ArrayInsert($aTest, $sIdx, 'Added Item 1|Added Item 2|Added Item 3|Added Item 4') MsgBox($MB_OK, 'Example 8', '_ArrayInsert returned error : ' & @error & @CRLF & 'with $sIdx = ' & $sIdx)
    1 point
  4. dave12077, TheXman is correct - the dreaded "different datatype comparison" bug strikes again! I cannot believe that no-one has run into this problem before - it seems very few people ever use this function with multiple range elements. M23
    1 point
  5. I think you may have found a bug. The @error = 3, in this case, is because it thinks that the indexes are out of order. It thinks that because it is doing string compares instead of numeric compares. If line #623, in the array.au3, is changed to look like the line below, it works fine. If Number($vRange[$i]) < Number($vRange[$i - 1]) Then Return SetError(3, 0, -1)
    1 point
  6. Subz

    Combine 32 & 64 Reg values

    I've never used that method, I've always used something like: Func _Uninstall() Local $sUninstallString = _GUICtrlListView_GetItemText($idListView, _GUICtrlListView_GetSelectionMark($idListView), 4) If StringStripWS($sUninstallString, 8) = "" Then Return -1 Return $sUninstallString EndFunc
    1 point
  7. You don't have to try only, you need to think also. For $i = 0 To ($iNumFrames - 1)     $oFrame = _IEFrameGetCollection($oIE, $i)     $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF Next Inside the above code you need to put your code from the first post. So that way for each frame found you need to try to get the button you want to click on as you dont know in which frame it is located!
    1 point
  8. Using Printer Management UDF : #include "PrintMgr.au3" Local $aPrinterProperties = _PrintMgr_EnumPrinterProperties("Lexmark CS310") If Not UBound($aPrinterProperties) Then Exit MsgBox(16, "Error", "Printer not found") Local $sPortName = $aPrinterProperties[0][60] Local $aTCPIPPorts = _PrintMgr_EnumTCPIPPrinterPort(), $sIP For $i = 0 To UBound($aTCPIPPorts) - 1 If $sPortName = $aTCPIPPorts[$i][0] Then $sIP = $aTCPIPPorts[$i][1] Next ConsoleWrite( ($sIP ? "IP address of the printer : " & $sIP : "Unable to find the printer IP address") )
    1 point
  9. The most likely issue is that the web site now requires secure connections to use newer TLS protocols. Windows 7, if not specifically updated, did not contain the definitions and services to use TLS 1.1 or 1.2. Windows 10 did come with these definitions and services. You can use this link to give you a starting point to understanding the possible issue and how to resolve it. Update to enable TLS 1.1 and TLS 1.2 as a default secure protocols in WinHTTP in Windows
    1 point
  10. Jos

    scite for autoit indent

    Yea I know and it is quite hard to make it perfect. Just look at AutoItIndentFix.lua for all corrections performed. In this case there is an issue with the retrieval of the previous header level when the last statement is an EndIf. Always open to suggestions when somebody has a solution for this one. Jos
    1 point
  11. i'll answer you in another 7 years from now.. You do realize, autoit has changed from then to now, it's possible there are going to be incompatibilities with those old scripts.
    1 point
×
×
  • Create New...