Deen Posted May 28, 2008 Share Posted May 28, 2008 WinActivate ("script.txt - Notepad") $Text = "Business Name" $Position = StringInStr($Text, " ") MsgBox(0, "trimmed text 2", StringTrimLeft($Text, $Position)) I would like the script to copy the entire line containing the string "Business Name" and remove "Business Name" to leave only titles. origanal Business Name Test Business removed Test Business i do not want a msgbox Please help Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 28, 2008 Share Posted May 28, 2008 WinActivate ("script.txt - Notepad")$Text = "Business Name"$Position = StringInStr($Text, " ")MsgBox(0, "trimmed text 2", StringTrimLeft($Text, $Position))I would like the script to copy the entire line containing the string "Business Name" and remove "Business Name" to leave only titles.origanal Business Name Test Businessremoved Test Business i do not want a msgboxPlease help ThanksStringInStr() gives the position of the first character in the match. To skip over the matching string, you want to add StringLen() to the position. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ResNullius Posted May 28, 2008 Share Posted May 28, 2008 i do not want a msgboxPlease help ThanksWhen you say you don't want a MsgBox, are you trying to replace the text in the notepad window? Link to comment Share on other sites More sharing options...
torels Posted May 28, 2008 Share Posted May 28, 2008 well... just get the notepad's window text make a stringsplit($string, @crlf) loop it checking for the string you want to search ($text) remove $text create a new file with the new value and start it in notepad Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
Deen Posted May 31, 2008 Author Share Posted May 31, 2008 I have copied the text from an IE page to notepad. I wish to copy the Entire Line containing the String "Business name" and past it into another notepad.The String "Business name" will then be removed.Would the above be easy to copy from the origanal IE page. if so how.?Thanks Link to comment Share on other sites More sharing options...
Deen Posted May 31, 2008 Author Share Posted May 31, 2008 I have copied the text from an IE page to notepad. I wish to copy the Entire Line containing the String "Business name" and past it into another notepad. The String "Business name" will then be removed. Would the above be easy to copy from the origanal IE page. if so how.? Thanks Link to comment Share on other sites More sharing options...
Deen Posted May 31, 2008 Author Share Posted May 31, 2008 I have copied the text from an IE page to notepad. I wish to copy the Entire Line containing the String "Business name" and past it into another notepad. The String "Business name" will then be removed. Would the above be easy to copy from the origanal IE page. if so how.? Thanks Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 31, 2008 Moderators Share Posted May 31, 2008 (edited) I have copied the text from an IE page to notepad. I wish to copy the Entire Line containing the String "Business name" and past it into another notepad. The String "Business name" will then be removed. Would the above be easy to copy from the origanal IE page. if so how.? ThanksLocal $sText = Your string to search here Local $sStringToFind = "Business Name" Local $aSRE = StringRegExp($sText, "(?i)\n(.*?" & $sStringToFind & ".*?)(?m:$|\r)", 1) If IsArray($aSRE) Then MsgBox(64, "Info", $aSRE[0])That might work. Edit: Or if I misunderstood you, you may only need StringReplace or StringRegExpReplace once you have the main string to replace the specific string "Business Name" Edited May 31, 2008 by SmOke_N 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...
ResNullius Posted May 31, 2008 Share Posted May 31, 2008 I have copied the text from an IE page to notepad. I wish to copy the Entire Line containing the String "Business name" and past it into another notepad. The String "Business name" will then be removed. ThanksSomething like this may work for you: this is a sample "script.txt" file that holds your source and should be open in notepad Businesss Name Test Business President's Name Joe Blow And this is the script to run against it WinActivate ("script.txt - Notepad") $originalText = ControlGetText("script.txt - Notepad","","Edit1") ;MsgBox(0,"",$originalText) $TextToStrip = "Business Name" $strippedText = StringReplace($originalText,$textToStrip,"") ;replace "Buisness Name" with nothing, removing it $strippedText = StringStripWS($strippedText,3) ;trim leading and trailing whitespace ;MsgBox(0,"",$strippedText) $changedFile = FileOpen("ScriptChanged.txt",2) ;open a file for writing, erasing previous contents FileWrite($changedFile,$strippedText) ;write the changed text to the file FileClose($changedFile) ; close the changed file for writing Run("notepad.exe ScriptChanged.txt") ; run notepad and open the changed file Of course I'm sure your "script.txt" file is more complex than that simple example, but it should give you the idea. Would the above be easy to copy from the origanal IE page. if so how.?It could be very easy, or maybe not Perhaps the _IE functions could help or InetGet(). Without seeing the page or a sample of the source hard to say what would be the best way. 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