Lakers Posted September 22, 2023 Share Posted September 22, 2023 Hello, Im new to autoit script and Im strucking with using Clipput from texts from a textdocument for line by line FileRead are easier to use just need to use Clipput(FileRead($filename), but FileReadLine are too way complicated I have checked severals thread but still cant find the right topic for my issue: local $file="example.txt" Func adresse() For $i = 0 to 3 Step 1 Clipput(FileReadLine($file) Send("v") Next Can someone put it example? Thanks in advanced Link to comment Share on other sites More sharing options...
ioa747 Posted September 22, 2023 Share Posted September 22, 2023 what do you want to do? Lakers 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Dan_555 Posted September 22, 2023 Share Posted September 22, 2023 (edited) I guess this is how you would read 3 lines out of a file into the clipboard and then paste it. local $file="example.txt" local $tmp="" For $i = 1 to 3 Step 1 $tmp=$tmp & FileReadLine($file, $i) & @crlf Next Clipput($tmp) Send("^v") Edited September 22, 2023 by Dan_555 Lakers 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Lakers Posted September 23, 2023 Author Share Posted September 23, 2023 Hello, what´s mean : local $tmp="" should I put file adresse or what should come between? Tried and still the clipput didnt work with the lines in files directed. Thanks in advanced Link to comment Share on other sites More sharing options...
Lakers Posted September 23, 2023 Author Share Posted September 23, 2023 I want to paste the lines copied in a file to the clipboard . Link to comment Share on other sites More sharing options...
Andreik Posted September 23, 2023 Share Posted September 23, 2023 To cite @Nine your request is clear as mud. Xandy 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Dan_555 Posted September 23, 2023 Share Posted September 23, 2023 (edited) local $tmp="" it defines the $tmp variable as local (i started writing your script as a function, but then i thought, for demonstration purposes, to remove the function and have left it there.) The script works, but it pastes the code anywhere it can. it reads 3 lines from the "example.txt". The example.txt needs to be in the same path where your script is. If it does not work, it may be because there is nothing that it can paste into. To test it, start the script then open the notepad and paste the clipboard content manually. Edited September 23, 2023 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
ioa747 Posted September 23, 2023 Share Posted September 23, 2023 expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Example() Func Example() ; C:\Program Files (x86)\AutoIt3\SciTE\Koda\history.txt Local $sFilePath = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 2, -1) - 1) & "\SciTE\Koda\history.txt" ; string to hold the lines Local $iLines = "1;4;10;25;39;50;63;70;75;104;113;128" ; convert to array for more convenient handling $iLines = StringSplit($iLines, ";") ; variable to hold the text from lines Local $sTXT = "" ; Read the lines 1;4;10;25;39;50;63;70;75;104;113;128 ; of the file C:\Program Files (x86)\AutoIt3\SciTE\Koda\history.txt ; to $sTXT For $i = 1 To $iLines[0] $sTXT &= "Line (" & $iLines[$i] & ") From ClipBoard: " & FileReadLine($sFilePath, $iLines[$i]) & @CRLF Next ;Writes text to the clipboard. ClipPut($sTXT) ; give some time Sleep(50) ; Run Notepad Run("notepad.exe") ; Wait max 3 seconds for the Notepad window to appear. Local $hNotePad = WinWait("[CLASS:Notepad]", "", 3) If WinActivate($hNotePad) Then ; paste Send("^v") EndIf EndFunc ;==>Example I know that I know nothing Link to comment Share on other sites More sharing options...
Lakers Posted September 24, 2023 Author Share Posted September 24, 2023 On 9/23/2023 at 4:15 PM, Dan_555 said: local $tmp="" it defines the $tmp variable as local (i started writing your script as a function, but then i thought, for demonstration purposes, to remove the function and have left it there.) The script works, but it pastes the code anywhere it can. it reads 3 lines from the "example.txt". The example.txt needs to be in the same path where your script is. If it does not work, it may be because there is nothing that it can paste into. To test it, start the script then open the notepad and paste the clipboard content manually. I tried with your code. The variable I put in $tmp= 5 and it put only clipboard 5 and not from the textdocument I sent. On 9/23/2023 at 5:16 PM, ioa747 said: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Example() Func Example() ; C:\Program Files (x86)\AutoIt3\SciTE\Koda\history.txt Local $sFilePath = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 2, -1) - 1) & "\SciTE\Koda\history.txt" ; string to hold the lines Local $iLines = "1;4;10;25;39;50;63;70;75;104;113;128" ; convert to array for more convenient handling $iLines = StringSplit($iLines, ";") ; variable to hold the text from lines Local $sTXT = "" ; Read the lines 1;4;10;25;39;50;63;70;75;104;113;128 ; of the file C:\Program Files (x86)\AutoIt3\SciTE\Koda\history.txt ; to $sTXT For $i = 1 To $iLines[0] $sTXT &= "Line (" & $iLines[$i] & ") From ClipBoard: " & FileReadLine($sFilePath, $iLines[$i]) & @CRLF Next ;Writes text to the clipboard. ClipPut($sTXT) ; give some time Sleep(50) ; Run Notepad Run("notepad.exe") ; Wait max 3 seconds for the Notepad window to appear. Local $hNotePad = WinWait("[CLASS:Notepad]", "", 3) If WinActivate($hNotePad) Then ; paste Send("^v") EndIf EndFunc ;==>Example I tried the code and it paste on the notbook following results: Line (1) From (ClipBoard: Release 1.7.3.0 build 252 (2010-07-30) Line (4) From (ClipBoard: Beta 1.7.2.9 build 250 RC2 (2010-06-29) Line (10) From (ClipBoard: Beta 1.7.2.8 build 247 RC1 (2010-04-15) Line (25) From (ClipBoard: Beta 1.7.2.7 build 241 (2010-03-25) Line (39) From (ClipBoard: Beta 1.7.2.6 build 229 (2010-03-15) Line (50) From (ClipBoard: Beta 1.7.2.5 build 222 (2010-03-02) Line (63) From (ClipBoard: Beta 1.7.2.4 build 214 (2010-02-18) Line (70) From (ClipBoard: Beta 1.7.2.3 build 207 (2010-02-11) Line (75) From (ClipBoard: Beta 1.7.2.2 build 204 (2010-02-04) Line (104) From (ClipBoard: Beta 1.7.2.1 build 191 (2009-07-09) Line (113) From (ClipBoard: Release 1.7.2.0 build 180 (2009-06-27) Line (128) From (ClipBoard: Release 1.7.1.0 (2009-04-27) It didnt paste the lines from the textfile I navigated. Thanks in advanced Link to comment Share on other sites More sharing options...
ioa747 Posted September 24, 2023 Share Posted September 24, 2023 what you posted is my script, which reads lines 1;4;10;25;39;50;63;70;75;104;113;128 from the file C:\Program Files (x86)\AutoIt3\SciTE\Koda\history.txt which is an example, that you should modify according to your needs where is yours script ? Lakers and Dan_555 2 I know that I know nothing Link to comment Share on other sites More sharing options...
Dan_555 Posted September 24, 2023 Share Posted September 24, 2023 (edited) 3 hours ago, Lakers said: I tried with your code. The variable I put in $tmp= 5 and it put only clipboard 5 and not from the textdocument I sent. The code is in he 3rd post of this thread. My second post explains your question. If you remember, you asked: Quote what´s mean : local $tmp="" and i gave you the explanation. As you can see: For $i = 1 to 3 Step 1 $tmp=$tmp & FileReadLine($file, $i) & @crlf Next is the correct usage of the variable $tmp. Edited September 24, 2023 by Dan_555 Lakers 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Lakers Posted September 25, 2023 Author Share Posted September 25, 2023 15 hours ago, Dan_555 said: The code is in he 3rd post of this thread. My second post explains your question. If you remember, you asked: and i gave you the explanation. As you can see: For $i = 1 to 3 Step 1 $tmp=$tmp & FileReadLine($file, $i) & @crlf Next is the correct usage of the variable $tmp. I get it. Thanks for your information. How can I put it automatic for each turn the FileReadLine increase by x lines? For example: The first time it will read line 1+2. Next time it will read 3+4 and so on? Thanks in advanced. 17 hours ago, ioa747 said: what you posted is my script, which reads lines 1;4;10;25;39;50;63;70;75;104;113;128 from the file C:\Program Files (x86)\AutoIt3\SciTE\Koda\history.txt which is an example, that you should modify according to your needs where is yours script ? Thanks for your coding. I have replaced your file directory to my desired file directory. Still no success. The Clipboard for FileReadLine remains blank. Quote Func Example() ; C:\Users\max\Downloads\test.txt Local $sFilePath = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 2, -1) - 1) & "C:\Users\max\Downloads\test.txt" ; string to hold the lines Local $iLines = "1;4;10;25;39;50;63;70;75;104;113;128" ; convert to array for more convenient handling $iLines = StringSplit($iLines, ";") ; variable to hold the text from lines Local $sTXT = "" ; Read the lines 1;4;10;25;39;50;63;70;75;104;113;128 ; of the file C:\Users\max\Downloads\test.txt ; to $sTXT For $i = 1 To $iLines[0] $sTXT &= "Line (" & $iLines[$i] & ") From (ClipBoard: " & FileReadLine($sFilePath, $iLines[$i]) & @CRLF Next ;Writes text to the clipboard. ClipPut($sTXT) ; give some time Sleep(50) ; Run Notepad Run("notepad.exe") ; Wait max 3 seconds for the Notepad window to appear. Local $hNotePad = WinWait("[CLASS:Notepad]", "", 3) If WinActivate($hNotePad) Then ; paste Send("^v") EndIf EndFunc ;==>Example Link to comment Share on other sites More sharing options...
ioa747 Posted September 25, 2023 Share Posted September 25, 2023 (edited) change this Local $sFilePath = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 2, -1) - 1) & "C:\Users\max\Downloads\test.txt" with this Local $sFilePath = "C:\Users\max\Downloads\test.txt" PS: and please use code tags when you post code on forum, it's more easy to read Edited September 25, 2023 by ioa747 Lakers 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Lakers Posted September 26, 2023 Author Share Posted September 26, 2023 Thanks so much for the helpful information. I'll try it. Link to comment Share on other sites More sharing options...
Lakers Posted September 26, 2023 Author Share Posted September 26, 2023 Hello, I still need help on the coding. How can I turn this into a Func and How can I put the variable increaase for each turn the FileReadLine by x lines? For example: The first running time it will read line 1+2. Next loop it will read lines 3+4 and so on? Thanks in advanced. Wishing everyone reading a great coding day. Link to comment Share on other sites More sharing options...
Solution ioa747 Posted September 26, 2023 Solution Share Posted September 26, 2023 Example() Func Example() Local $sTxtFile = "C:\Users\max\Downloads\test.txt" Run("notepad.exe") ; Run Notepad Local $hNotePad = WinWait("[CLASS:Notepad]", "", 3) If WinActivate($hNotePad) Then For $i = 1 To 5 _GetLinesToClip($sTxtFile) Send("^v") ;give time to see result Sleep(2000) Next EndIf EndFunc ;==>Example ;---------------------------------------------------------------------------------------- Func _GetLinesToClip($sFilePath, $LineCnt = 2) Local Static $iLines = 0 Local $sTXT = "" For $i = 1 To $LineCnt $iLines += 1 $sTXT &= "Line (" & $iLines & ") " & FileReadLine($sFilePath, $iLines) & @CRLF Next ClipPut($sTXT) Sleep(50) EndFunc ;==>_GetLinesToClip ;---------------------------------------------------------------------------------------- Lakers 1 I know that I know nothing Link to comment Share on other sites More sharing options...
Lakers Posted September 27, 2023 Author Share Posted September 27, 2023 Thanks for your help. I´ll check it later. Have a nice day. Link to comment Share on other sites More sharing options...
Lakers Posted September 27, 2023 Author Share Posted September 27, 2023 local $file="example.txt" local $tmp="" For $i = 1 to 3 Step 1 $tmp=$tmp & FileReadLine($file, $i) & @crlf Next Clipput($tmp) Send("^v") How can I put this into a func with my desired requirements above? " How can I turn this into a Func and How can I put the variable increaase for each turn the FileReadLine by x lines? For example: The first running time it will read line 1+2. Next loop it will read lines 3+4 and so on?" Thanks in advanced!!! Link to comment Share on other sites More sharing options...
ioa747 Posted September 27, 2023 Share Posted September 27, 2023 I don't understand what you want, everything you ask is already ready, you just have to learn to use it. After reading the two lines from the text file, what do you do next? I know that I know nothing Link to comment Share on other sites More sharing options...
Lakers Posted September 27, 2023 Author Share Posted September 27, 2023 I´m working on the coding from @Dan_555 It should be put in a func and for each turn the variable of reading line increse by x times. If you can help me with thtat code it will be very helpful. Thanks 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