kemo1987 Posted November 12, 2011 Share Posted November 12, 2011 Hello again and sorry for annoyingwell i tried to make that with 3 different arrays but it sent all ip then all user then all pass.so i made one array and use StringSplit with "," to split every line to 3 elements$ip=$data[0] give number of elements for each line i mean > 1 for first line and 3 for other lines$user=$data[1] this give me 4 then ip $pass=$data[2] give errorwhat i want is :for every line in the filesend $ip > tab > $user > tab > $pass >tab > enterand i want it look like this122.33.23.241 friz k01122.73.213.22 ffri 102122.33.23.243 frss 103122.73.213.24 jiis tt04=========================siplist.txt contain more than 100 lines like this:122.33.23.241,friz,k01122.73.213.22,ffri,102122.33.23.243,frss,103122.73.213.24,jiis,tt04=======================; Get the files into arrays #include<Array.au3> #include <File.au3> Global $aFile_sip[3] _FileReadToArray("siplist.txt", $aFile_sip) ;_ArrayDisplay($aFile_sip, "ip Array") For $line In $aFile_sip $data=StringSplit($line, ",") $ip=$data[0] ; first elemnt in array $user=$data[1] ;second $pass=$data[2] ;third > i got error here illegal charcter WinWaitActive("[CLASS:Notepad]") ; JUST FOR TRY BUT IT WILL SEND TO ANOTHER APP Send($ip) send("{TAB}") Send($user) send("{TAB}") Send($pass) send("{TAB}") send("{ENTER}") Next Link to comment Share on other sites More sharing options...
water Posted November 12, 2011 Share Posted November 12, 2011 (edited) Change the For loop in your script because you start with the first element in the array and this element keeps the number of elements (in your example 4).; Get the files into arrays #include<Array.au3> #include <File.au3> Global $aFile_sip[3] _FileReadToArray("siplist.txt", $aFile_sip) ;_ArrayDisplay($aFile_sip, "ip Array") For $iIndex = 1 To $aFile_sip[0] $data = StringSplit($aFile_sip[$iIndex], ",", 2) ; <== modified so the array doesn't contain the counter in $data[0] $ip = $data[0] ; first elemnt in array $user = $data[1] ;second $pass = $data[2] ;third > i got error here illegal charcter WinActivate("[CLASS:Notepad]") ; JUST FOR TRY BUT IT WILL SEND TO ANOTHER APP Send($ip) Send("{TAB}") Send($user) Send("{TAB}") Send($pass) Send("{TAB}") Send("{ENTER}") NextEdit:modified so the array doesn't contain the counter in $data[0] Edited November 12, 2011 by water kemo1987 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Zedna Posted November 12, 2011 Share Posted November 12, 2011 (edited) #include #include Global $aFile_sip[3] _FileReadToArray("siplist.txt", $aFile_sip) ;_ArrayDisplay($aFile_sip, "ip Array") For $line In $aFile_sip $data = StringSplit($line, ",") ConsoleWrite(_ArrayToString($data) & @CRLF) Next ConsoleWrite('***' & @CRLF) For $i = 1 To $aFile_sip[0] $line = $aFile_sip[$i] $data = StringSplit($line, ",") ConsoleWrite(_ArrayToString($data) & @CRLF) Next EDIT: result 1|4 3|122.33.23.241|friz|k01 3|122.73.213.22|ffri|102 3|122.33.23.243|frss|103 3|122.73.213.24|jiis|tt04 *** 3|122.33.23.241|friz|k01 3|122.73.213.22|ffri|102 3|122.33.23.243|frss|103 3|122.73.213.24|jiis|tt04 Edited November 12, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Malkey Posted November 12, 2011 Share Posted November 12, 2011 Here is another method. Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send(StringStripCR(StringReplace(FileRead("siplist.txt"), ",", @TAB))) Link to comment Share on other sites More sharing options...
kemo1987 Posted November 12, 2011 Author Share Posted November 12, 2011 Thank you All i tried first solution and work so good Link to comment Share on other sites More sharing options...
Malkey Posted November 12, 2011 Share Posted November 12, 2011 kemo1987, water, and Zedna Please look at value in $data[0] that is returned from $data=StringSplit($line, ","), or, $data = StringSplit($aFile_sip[$iIndex], ","). Evidently the number of strings returned "work so good". " $ip = $data[0] ", I don't think so. Malkey Link to comment Share on other sites More sharing options...
water Posted November 12, 2011 Share Posted November 12, 2011 Malkey, you are right, that's a bug. I changed my code so that StringSplit doesn't return the counter in $data[0]. $data = StringSplit($aFile_sip[$iIndex], ",")to$data = StringSplit($aFile_sip[$iIndex], ",", 2) My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Zedna Posted November 12, 2011 Share Posted November 12, 2011 (edited) @Malkey I added result of my educative script for you EDIT: I just pointed to the source of problem which is nicely seen from my example Edited November 12, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
kemo1987 Posted November 12, 2011 Author Share Posted November 12, 2011 (edited) i see what u talking about so i used$data[1] ip$data[2]user$data[3]passit work good but i think to edit it to$data = StringSplit($aFile_sip[$iIndex], ",", 2)thank you for help Edited November 12, 2011 by kemo1987 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