cutedog09 Posted November 29, 2005 Posted November 29, 2005 I'm a newbie so pls help me...I want to select & copy-paste one line at a time from txt document.So my problem is: 1)How to make AutoIt copy and paste one line at a time from a text file with/without it being open in Notepad?2)how do i keep track of my position in the txt document ?(.ie. which line is to be copied next) I'm new to scripting(2days ) but familiar with programming(C/C++)Any help on this wud b appreciated..thanx in advance (Thanx to Lxp )
BigDod Posted November 29, 2005 Posted November 29, 2005 I'm a newbie so pls help me...I want to select & copy-paste one line at a time from txt document.So my problem is: 1)How to make AutoIt copy and paste one line at a time from a text file with/without it being open in Notepad?2)how do i keep track of my position in the txt document ?(.ie. which line is to be copied next) I'm new to scripting(2days ) but familiar with programming(C/C++)Any help on this wud b appreciated..thanx in advance (Thanx to Lxp )Lookup FileReadLine in the help file. Remember to look at the example. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
ChrisL Posted November 29, 2005 Posted November 29, 2005 So what exactly do you want to do after each line? This part of a script, read a file one line at a time and wrote it to another file, when it found the line I was looking for it edited the string and wrote it to the new file, then moved on and copied the rest of the original file to the new file. Then it deletes the original file and renames the temp file to the old name. Maybe you can get some ideas from it? $file = FileOpen($Path & "Messages\English\messages.txt", 0) _FileCreate ( $Path & "Messages\English\Messages.tmp" ) $NewFile = FileOpen ( $Path & "Messages\English\Messages.tmp", 2 ) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open Messages.txt") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $result = StringInStr($line, "IDS_PAPER_TYPE_MATTE ""Matte""") If $Result =0 then ;do nothing until Filewriteline to copy original text to tmp file Else $Line = @tab & "IDS_PAPER_TYPE_MATTE ""Lustre""" Endif FileWriteLine ($NewFile, $Line) Wend FileClose ( $File ) FileClose ( $NewFile ) FileDelete ( $Path & "Messages\English\messages.txt" ) FileMove($Path & "Messages\English\Messages.tmp", $Path & "Messages\English\Messages.txt") [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
LxP Posted November 30, 2005 Posted November 30, 2005 Perhaps you're after this. Simply change the first line to point to any existing text file. Local Const $File = @ScriptDir & '\Lines.txt' Global $Handle = FileOpen($File, 0) If $Handle = -1 Then MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $File) Exit EndIf HotkeySet('^{RIGHT}', 'NextLine') HotkeySet('{ESC}', 'Done') NextLine() While 1 Sleep(0x7FFFFFFF) WEnd Func NextLine() Local $NextLine = FileReadLine($Handle) If @Error Then MsgBox(0x40, 'End of File', 'The end of the file has been reached.') Done() EndIf ClipPut($NextLine) TrayTip('Copied to Clipboard', $NextLine & @LF & @LF & 'Ctrl+Right: Next line' & @LF & 'Esc: Quit', 5, 1) EndFunc Func Done() FileClose($Handle) Exit EndFunc
cutedog09 Posted November 30, 2005 Author Posted November 30, 2005 WOW!!...my prob. solved!! ..special thanx to LxP and ChrisL for taking the trouble to post scripts..i wud surely analyse them further to learn more...and i'm also thankful to BigDod for showing me the way. I feel good to b the part of this community
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