Yep, I'm writing these things up like daily now. This lesson will cover
finding the chat room, counting mails, and subclassing. Again, please don't
try to read this unless you have read and understood (completely) the first
two lessons. IM or email me requesting them.

--= Finding the Chat Room.

This requires the use of FindChildByTitle, FindChildByClass, and knowing how
to locate AOL's MDI Client. The chat room is one of the hardest windows to
locate. Its actually simple once you learn it though. Since the title of the
chat room window is ALWAYS changing, you need to find it some other way. You
have to look at each window (using the same principles as you used in making
your FindChildByxxxx functions) with GW_CHILD and GW_HWNDNEXT, then look for
these 4 items on each window :

1. "_AOL_VIEW" by class
2. "_AOL_EDIT" by class
3. "Send" by title
4. "_AOL_LISTBOX" by class

The window that has all 4 of these items will by your chat window. If you
understood FindChildByClass and FindChildByTitle in the last lesson, this
should be simple for you to accomplish.


--= Counting Mails

This is actually a very easy thing to do. Locate "New Mail" by title under
the MDI Client, and then locate "_AOL_TREE" under the New Mail box. This is
the listbox with all the dates, screen names, and mail titles. You have to
use SendMessagebyNum to get the number of mails in it. I'm gonna tell you how
to get the mail count, but I'm gonna leave it to you to figure out how what
to do if there is no New Mail box open (you can either try to open it or tell
them to open it) and how to figure out when all the mail is in the box. I'll
tell you that it has nothing to do with the hourglass. Here's how you ask the
_AOL_TREE how many items are in it

Count% = SendMessagebyNum(AOLTREEhandle%, LB_GETCOUNT, 0, 0&)

Not as hard as you thought huh? Next section.


--= Subclassing!

This is a toughy and you have to really think about it to understand it.
Windows passes messages around from item to item, things like the LB_GETCOUNT
you did when you read the number of mails, or the WM_SETTEXT in the last
lesson. Well, with a subclassing VBX like VBMSG (there are others but my
examples will be with VBMSG) you can intercept these messages! You might ask,
how can this help me? Well, every time AOL sends in a new line of chat or a
line in an Instant Message, your AOL software updates something like the chat
room's _AOL_VIEW or creates a new window for an Instant Message. If you
locate an item's handle and use

VBMsg1.SubClasshWnd = ItemHandle%

Then that VBMSG will look at that item and intercept messages. Now you have
to tell it WHICH messages your interested in. When AOL updates the chat room,
for example, it calls a WM_SETTEXT on the _AOL_VIEW child. When a new window
comes up, like an Instant Message, a WM_MDICREATE is triggered on the
MDIClient. If you were to subclass the chat room this way with WM_SETTEXT,
the VBMsg1_WindowMessage event would run every time there was a new line of
chat. You could use this to run events like getting chat text or logging or
anything else. Once you've done this, this line of code

S$ = agGetStringfromLPSTR$(LParam) 

Will get whats being added to the _AOL_VIEW. Then you can use your Left$ and
InStr and Right$ and Mid$ functions to get the screen name of the person
talking and what they said, etc. Don't jump up and go making a bot just yet
though, cause subclassing things and intercepting messages is a pretty
powerful thing, not just for AOL, but for other applications. You could
experiment with subclassing things in Word Perfect or Program Manager, etc.
What am I saying? You can actually use all this to make something besides an
"aohack"! So mess around with it, sometimes you'll get GPFs but you'll get
the hang of it eventually.

Lastly, I just want to throw something in that isnt really API but its a
question that I've been asked like 4 times in the last day. How do you make
things happen when the mouse is moved over an object, like changing a label
caption. Well, the event is called MouseMove, and it can be found in the same
place as an item's Click event if you use the second pull down bar on the
source code window in VB.

Email/IM ideas for the next lesson, I'm kinda running short now. Have fun and
try to *understand* all this, not just use it.

EV   iVe  
