Sign in to follow this  
Followers 0
estemarito

remove word from text?

5 posts in this topic

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)

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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!!

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by 99ojo

Share this post


Link to post
Share on other sites

yeah! thank you very much! now works perfect!

solved!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0