Naum
2009-01-28 16:10:51
FindChatBoxText and GetChatBox Text
Table Of Contents!
I - Intro
II - Parameters
III - Usage
I - Intro
Hello and weclome to this tutorial, I made this tutorial when I was in the process of making and auto responder for a script. These are two of the most crucial functions used in Auto Responders.
GetChatBoxText
II - Parameters
This function gets a string of text from a specified line which is a specified color. The description goes as so:
{*******************************************************************************
function GetChatBoxText(Line, TextCol: Integer): string;
By: ZephyrsFury
Description: Gets text on the line Line with colour TextCol. (Line 1 is the top,
Line 8 is the bottom line).
Colours:
clMessage/clBlack - Black text messages ("Oh Dear you are dead", etc).
clChat/clBlue - Chat messages from you and other players.
clTrade/clPurple - Colour of trade request text.
clFriend - Colour of friend and clan chat.
Works with other colours too.
*******************************************************************************}
First parameter is the line you want to get it at, just to make it n00b pr00f:

The numbers (yes, they are very deformed ways of writing numbers :p) on the side of that box corresponds to the one in the red box.
The second is for the different colors, so for trade messages you would use clPurple or ClTrade for chat you would use clBlue or clChat. Good 'ol Zephy's made it easy.
III - Usage
So, If you wanted to get text which is the most recent and is of Black color you would use this code:
WriteLn(GetChatBoxText(8 ,clBlack);this is very useful, but it can be much more useful, as it outputs all the text of the line - you can crop parts of it, for instance:S := Between('oh', 'you are', GetChatBoxText(8 ,clBlack));
If S = 'Dear' Then
WriteLn('We are dead!!!')
Else
WriteLn('We are not dead, yet!!');^ note that S must be a 'string' variable ^.Pretty l33t, huh?
Not even as cool as this:
For I := 1 to 8 Do
WriteLn('Chatter '+IntToStr(I)+' Said: '+GetChatBoxText(I ,clBlack)+' !'); To make it search from bottom to top :
For I := 8 Downto 1 Do
WriteLn('Chatter '+IntToStr(I)+' Said: '+GetChatBoxText(I ,clBlack)+' !'); So you can use it for anything basically.
——————————————————————————–
FindChatBoxText
II - Parameters
This function uses GetChatBoxText to see if a substring(text) is in a string found by its parent function.
Description:
{*******************************************************************************
function FindChatBoxText(Text: string; Line: Integer; TextCol: Integer): Boolean;
By: ZephyrsFury
Description: Searches for Text on Line with colour TextCol. True if found.
*******************************************************************************}
Text is the text your searching for and Line is the line it is at, my diagram:

And the TextCol could be anything from this:
clMessage/clBlack - Black text messages ("Oh Dear you are dead", etc).
clChat/clBlue - Chat messages from you and other players.
clTrade/clPurple - Colour of trade request text.
clFriend - Colour of friend and clan chat. - Since it uses GetChatBoxText.III - Usage
Remember what I said about using the between function?? Well this is basically that procedure compiled into this. I found find this easier to use, So you can use it to find some text instead of getting text then comparing it ;).
You cannot use this in WriteLn as it is a boolean, but you could use it in this context:
If FindChatText('ello', 8, clChat) Then
TypeSend('yow!!');But you can also use it with a for and to do statement ;):
For I := 1 to 8 Do
If FindChatText('ello', I, clChat) Then
TypeSend('yow!!');:).
Thanks, for listening!!