pokwuk Posted May 1, 2011 Share Posted May 1, 2011 Hi folks , Im pretty new to autoit , i had a read through the forum , and searched on google but couldnt find anything . Also couldnt find anything on helpfile. What i wanted to do is replace some text on a particular part of a line(only 1 long line). this is what i was trying , which obviously didn't work $text = WinGetText("[CLASS:Notepad]", "") $textFile = _StringBetween($text , "my name is >", "and i have a hat") _FileWriteToLine( $textFile, 1, send("^v"), 1) so i wanted to replace the text between those , like "my name is "jon" and i have a hat" , i wanted to replace the "jon" for something else that was copied from another .txt Thanks Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 1, 2011 Moderators Share Posted May 1, 2011 There you go again not reading the help file and seeing how to use functions ( again, _StringBetween() returns an array ). If I'm not mistaken, I gave you a wiki page where to learn as well.... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
enaiman Posted May 1, 2011 Share Posted May 1, 2011 (edited) You might want to have a look at ClipGet Also, you are using badly the filename ...$textFile needs to be an actual file location and that file must exist - your script is returning a string (probably "Jon") and of course that is not a valid file name.It would have been an useful exercise for you to get this working on your own but, here is the script - try to understand what I did#Include <File.au3> #Include <String.au3> $text = WinGetText("[CLASS:Notepad]", "") $textFile = "C:\result.txt" If Not FileExists($textFile) Then FileClose(FileOpen($textFile, 2)) EndIf $nameToReplace = _StringBetween($text , "my name is >", "and i have a hat") _FileWriteToLine( $textFile, 1, StringReplace($text, $nameToReplace[0], ClipGet()), 1)Well ... I shouldn't have offered the code since the OP was already sent to a helpful Wiki page ... now I did it - sorry SmOke_N Edited May 1, 2011 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 1, 2011 Moderators Share Posted May 1, 2011 Well ... I shouldn't have offered the code since the OP was already sent to a helpful Wiki page ... now I did it - sorry SmOke_NNo problem, most of us like to flex our knowledge base by providing solutions.However, I think sometimes we forget, as helpful as the forum is, we really didn't get that knowledge by hoping someone would just fix our code.More than likely, we got it from reading and learning how things work before/during/after we used them. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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