estemarito Posted March 24, 2010 Share Posted March 24, 2010 hello, I have a text and trying to erase the word "tree" this word appears many times. I would remove it or replace it with a blank space. i try this, but dont works: WinWaitActive ("text.txt") ; Here i open the text $sExtract = StringRegExpReplace ("tree", " ", " ") ClipPut($sExtract) Link to comment Share on other sites More sharing options...
99ojo Posted March 24, 2010 Share Posted March 24, 2010 Hi, if i understand what you want: 1) You have text.txt 2) you want to replace 'tree' with a blank 2 possibilities: 1) String manipulation, leaving text.txt as it was: $string = FileRead (@ScriptDir & "\text.txt") ; text.txt is in same folder as your script $string = StringReplace ($string, "tree", " ") ClipPut ($string) 2) Change 'tree' straight in text.txt #include <file.au3> _ReplaceStringInFile (@ScriptDir & "\text.txt", "tree", " ") ClipPut (FileRead (@ScriptDir & "\text.txt")) ;-)) Stefan Link to comment Share on other sites More sharing options...
estemarito Posted March 24, 2010 Author Share Posted March 24, 2010 THANKS!!! works fine for files... but if i want use for an active window ( ej: "No Title") what is wrong here? $sin = WinActivate ("No Title") $string = FileRead ($sin) $string = StringReplace ($string, "tree", " ") ClipPut ($string) Thanks for your help!! Link to comment Share on other sites More sharing options...
99ojo Posted March 24, 2010 Share Posted March 24, 2010 (edited) Hi, you are using File command to read out text from a window -> never works. See helpfile for further information: ControlGetText () Use example script to see whats going on. If you don't use notepad, use AutoIt v3 Window Info to get the class of your window. If you have the class information, you can read the text into variable. Then you can start string manipulation. ;-)) Stefan Edited March 24, 2010 by 99ojo Link to comment Share on other sites More sharing options...
estemarito Posted March 24, 2010 Author Share Posted March 24, 2010 yeah! thank you very much! now works perfect! solved! 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