the_lord_mephy Posted October 20, 2004 Share Posted October 20, 2004 Is there a way to get characters between two given strings? For example: I want to go to school now. If i wanted to see where they wanted to go do like StringBetween("to ", " now") And it would return school. (Stupid example and i know theres no such thing as "stringbetween") My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
this-is-me Posted October 20, 2004 Share Posted October 20, 2004 (edited) There is in my world: Func stringbetween($str, $start, $end) $pos = StringInStr($str, $start) If Not @error Then $str = StringTrimLeft($str, $pos + StringLen($start) - 1) $pos = StringInStr($str, $end) If Not @error Then $str = StringTrimRight($str, StringLen($str) - $pos + 1) Return $str EndIf EndIf EndFunc Edited October 20, 2004 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
scriptkitty Posted October 20, 2004 Share Posted October 20, 2004 Make your own. $x="I want to go to school now." $answer=StringBetween($x,"want to ", " now") MsgBox(1,"Answer",$answer) Func StringBetween($in,$_to, $_now) If StringInStr($in,$_to)>0 and StringInStr($in,$_now)>0 Then $out=StringTrimLeft($in,StringInStr($in,$_to)+StringLen($_to)-1) $out=StringTrimRight($out,StringLen($out)-StringInStr($out,$_now)) Return $out Else Return "Error" EndIf EndFunc AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Josbe Posted October 20, 2004 Share Posted October 20, 2004 Of course, with String* functions you could do these. (an UDF) (Perhaps somebody is doing it or it was done before in the forum.) • AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
Josbe Posted October 20, 2004 Share Posted October 20, 2004 (edited) Make your own.$x="I want to go to school now." $answer=StringBetween($x,"want to ", " now") MsgBox(1,"Answer",$answer) Func StringBetween($in,$_to, $_now) If StringInStr($in,$_to)>0 and StringInStr($in,$_now)>0 Then $out=StringTrimLeft($in,StringInStr($in,$_to)+StringLen($_to)-1) $out=StringTrimRight($out,StringLen($out)-StringInStr($out,$_now)) Return $out Else Return "Error" EndIf EndFunc<{POST_SNAPBACK}>Like I said "somebody is doing it"...Someone fast, like Scriptkitty. EDIT: typo Edited October 20, 2004 by josbe • AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
scriptkitty Posted October 20, 2004 Share Posted October 20, 2004 Maybe, but not always the fastest. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 20, 2004 Share Posted October 20, 2004 Winner: This-is-me Link to comment Share on other sites More sharing options...
the_lord_mephy Posted October 21, 2004 Author Share Posted October 21, 2004 (edited) Alright well I've been trying for a long time lol.I have the text<Username> :+: (S.### .... other textAnd i want to retrieve the number and read that numbers file line. I don't know what to set x as Edited October 21, 2004 by the_lord_mephy My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 21, 2004 Share Posted October 21, 2004 Change it to an if statement, for all the answers to the trivia questions you are cheating on! LoL. Just make an in If then statement for each answer, then use the above scripts to make it work. Good luck. Link to comment Share on other sites More sharing options...
Valik Posted October 21, 2004 Share Posted October 21, 2004 Larry, don't accuse people of thinking unless you have indisputable proof that they indeed are thinking. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 21, 2004 Share Posted October 21, 2004 What he means is that he has a chat client... What shows up on the screen is <Username> :+: (S.### etc...) He only wants to show the etc... Thats why he made this topic. Good point Valik. Link to comment Share on other sites More sharing options...
the_lord_mephy Posted October 21, 2004 Author Share Posted October 21, 2004 Black, you always know what my scripts are for lol. Valik, I am thinking and just because I'm not an Uber Coder like you, it doesn't mean you have to put me down, Jeez.(I'm asking for it )Larry,I am in a channel on a Battle.net game. In the channel there is a bot that says scrambled words in the following format. (Username is the account name of the bot pretend the word is abhor):<Username> :+: (S.Number -> ahrobThe Number is the number of the word that is being scrambled. (Which is read from a file in the format):Word1Word2Word3Word4Word5Word6Word7etc.The Number changes depending on the words location in the file.What I want to do is have the bot Find the number of the question and send the answer. My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
scriptkitty Posted October 21, 2004 Share Posted October 21, 2004 (edited) $x="I want to take you password LeetDawg#78321!" ; or might try $x=$line if useing this in some filereadline() $answer=StringBetween($x,"#", "!") ; or $answer=Number(StringBetween($x,"#", "!")) MsgBox(1,"Answer",$answer) Func StringBetween($in,$_to, $_now) If StringInStr($in,$_to)>0 and StringInStr($in,$_now)>0 Then $out=StringTrimLeft($in,StringInStr($in,$_to)+StringLen($_to)-1) $out=StringTrimRight($out,StringLen($out)-StringInStr($out,$_now)+1) Return $out Else Return "Error" EndIf EndFuncnow you should research FileReadLine and such things, maybe you can read the file and when it finds a number instead of "Error" you can have it mark down the line number and the number it returned..... any resemblance to actually understanding what was said in:Alright well I've been trying for a long time lol.I have the text<Username> :+: (S.###Â .... other textAnd i want to retrieve the number and read that numbers file line. I don't know what to set x as is purely coincidental! Edited October 21, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Valik Posted October 21, 2004 Share Posted October 21, 2004 It was a casual comment. If you take offense to it, that is your decision to make, however, it was not directed to you in particular but rather to Larry's comment in general. Link to comment Share on other sites More sharing options...
the_lord_mephy Posted October 21, 2004 Author Share Posted October 21, 2004 Larry,<Username> :+: (S.Number -> ahrob Would only apply if the word was abhor. If the word was glass it would look like this<Username> :+: (S.Number -> lsgsaOr something similar.The Number is the number is declared by the word (that is being scrambled)'s place in the word file. What the scramble bot does is, it has a list of words in a .dat file. that looks like the following:Word1Word2Word3Word4Word5Word6Word7etc.It selects a word at random, mixes up the letters, and sends that text in the channel. The other people in the channel need to unscramble that word and enter it. I'm trying to make a bot that does that automatically just for fun. If abhor was the 153rd word in the .dat file, the bot would Send this:<Username> :+: (S.153 -> ahrobMy bot will look at the string in between ":+: (S." and " ". (returning the number 153) it would then execute $word = FileReadLine("allwords.dat", "153") Send($word)Hopefully that's a little easier to understand.Thanks for your patience.@ValikI don't take anything said to me on the computer offensively. My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
scriptkitty Posted October 21, 2004 Share Posted October 21, 2004 ah, now that makes more sence. I was guessing at what you meant. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scriptkitty Posted October 21, 2004 Share Posted October 21, 2004 ok, is the number the only thing the bot gives? If so you could eliminate a lot of that code AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
scriptkitty Posted October 21, 2004 Share Posted October 21, 2004 (edited) Ok, doesn't really matter much. If you can read the text in some way, just set it to read the text and then use any of the function given here pretty much. You may want to make it a number. Say use Larry's code: $string = "<Username> :+: (S.153 -> ahrob" $num = number(stringbetween($string,":+: (S."," ->")); slight modification $word = FileReadLine("allwords.dat", $num) Send($word) MsgBox(4096,$word,$num") Func stringbetween($str, $start, $end) $pos = StringInStr($str, $start) If Not @error Then $str = StringTrimLeft($str, $pos + StringLen($start) - 1) $pos = StringInStr($str, $end) If Not @error Then $str = StringTrimRight($str, StringLen($str) - $pos + 1) Return $str EndIf EndIf EndFunc Edited October 21, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
the_lord_mephy Posted October 21, 2004 Author Share Posted October 21, 2004 Yeah, I can get that that is a beautiful code. However, I don't know how to get a correct value for $string. I want it to update everytime the bot sends a new scrambled word. My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
normeus Posted October 21, 2004 Share Posted October 21, 2004 Yeah, I can get that that is a beautiful code. However, I don't know how to get a correct value for $string. I want it to update everytime the bot sends a new scrambled word.<{POST_SNAPBACK}>so you dont have the string ?Alright well I've been trying for a long time lol.I have the text<Username> :+: (S.### .... other textAnd i want to retrieve the number and read that numbers file line. I don't know what to set x asso you do have the string!I got this part of the question!!! remember the old (old old ) games where in order to start the game you hadto answer a question like this: enter the 5th word on page 6 of the manualwell, his number is the nth record on a file.( here's some code to be used for a useless game) $number= StringMid ( $line,(StringInStr($line,"(S.")+3),3) ; the number is always 3rd character on the line(of course copy Larry's code which has enough error checking to be used in an airport and put it to good use, business use that is.) to get $line you could :WinWaitActive("Untitled - Notepad") ;works for notepad$lines = WinGetText("Untitled - Notepad","") ;and it came from Help file$linearray=StringSplit ($lines,@LF)$line=$linearray[$linearray[0]-2] ;play with the index -3 ?MsgBox(0, "line read was:"&$linearray[0], $line)but of course there is the 64kb limit so you would have to make sure the lines that scroll over the top are deleted and I did a minus 2 on the array index in case the program you are using keeps an empty line at the end of the windowI figure this code will at least make others post so I didnt put any effort into it (I have no shame on my copy/paste abilities )P.S. I find myself reading this forum every single night just to enjoy the nutty replies to the even nuttiest (can you say jiffy ) questions from scriptkitty trying to teach people how to fishto valik's "are you stupid or just plain mental" commentsand of course the questions " I need a mouse left 100 and I need it NOW"every one makes autoit3 even better. http://www.autoitscript.com/autoit3/scite/...iTe4AutoIt3.exe 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