|
-
Jun 20th, 2003, 02:01 AM
#1
Thread Starter
New Member
AIM Log in .NET
I've been searching all over for a successful way to find the chat window of AIM and get it's text. I've found plenty on using the API (FindWindow, FindWindowEx, etc). What I have so far is:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Public Function FindIM() As Long
Dim hWnd As Integer
Dim AteClass As Integer
FindIM = FindWindow("AIM_IMessage", vbNullString)
Dim AteClass2 As Integer
Dim WndAteClass As Integer
WndAteClass = FindWindowEx(FindIM, 0, "WndAteClass", vbNullString)
AteClass = FindWindowEx(WndAteClass, 0, "Ate32Class", vbNullString)
End Function
which seems to get the window handles fine, but all attempts to retrieve the text have failed (empty string returned). Most of the code in the forums search is VB6 which needs some tweaking, and i'm probably tweaking something the wrong way. If anyone has any suggestions, or an alternative, easier, or more effective way to do this in .NET, I would really appreciate it
-
Jun 20th, 2003, 09:04 AM
#2
Sleep mode
Try changing long variables in FindWindowExA to integer .
-
Jun 20th, 2003, 11:07 PM
#3
Thread Starter
New Member
Doesn't seem to solve the problem I can get the caption of the IM window fine, and the handle of the im text window, but the string is always null when getting text from the im text window. Here's more of my code:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Public Declare Ansi Function GetWindowText Lib "User32.dll" Alias "GetWindowTextA" ( _
ByVal hwnd As Integer, _
ByVal lpString As String, _
ByVal nMaxCount As Integer) As Integer
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Integer) As Integer
Public Function FindIM() As Long
Dim hWnd As Integer
Dim AteClass As Integer
FindIM = FindWindow("AIM_IMessage", vbNullString)
Dim AteClass2 As Integer
Dim WndAteClass As Integer
WndAteClass = FindWindowEx(FindIM, 0, "WndAte32Class", vbNullString)
AteClass = FindWindowEx(WndAteClass, 0, "Ate32Class", vbNullString)
FindIM = API_GetText(AteClass)
End Function
Public Function API_GetText(ByVal hWnd As Integer)
Dim Ret As Integer
Dim s As String
Ret = GetWindowTextLength(hWnd)
Call GetWindowText(hWnd, s, Ret + 1)
API_GetText = s
End Function
-
Jun 23rd, 2003, 08:29 AM
#4
Fanatic Member
Try using WM_GETTEXT and WM_GETTEXTLENGTH with SendMessage. Keep in mind that you can only retrieve a certain amount -- IIRC, ~80k characters. I forget how you deal with images in IM's... (I've done this before, and made away messages that are sent only to certain people). An alternative is to hack into AIM's memory with ReadProcessMemory (you can hack into games too ).
You're in luck, I have some VB6 code that gets the text from a window using SendMessage. Remeber to change longs to integers and I think the "as Any" will work "as Integer" (you can't use "as Any" in .NET).
VB Code:
Public Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Const WM_SETTEXT = &HC
Public Const WM_GETTEXTLENGTH = &HE
Public Function TrimNull(s As String) As String
Dim n As Integer
n = InStr(s, vbNullChar)
If n >= Len(s) Then
TrimNull = Left$(s, InStr(s, vbNullChar) - 1)
Else
TrimNull = ""
End If
End Function
Public Function GetText(hWnd As Long) As String
Dim nSize As Integer
Dim sRet As String
nSize = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0)
nSize = nSize + 1
sRet = Space$(nSize)
SendMessage hWnd, WM_GETTEXT, nSize, ByVal sRet
GetText = TrimNull(sRet)
End Function
-
Jun 23rd, 2003, 08:30 AM
#5
Fanatic Member
From MSDN: Rich Edit: If the text to be copied exceeds 64K, use either the EM_STREAMOUT or EM_GETSELTEXT message.
I tried EM_STREAMOUT and failed (crashing the IDE and everything). I'm not sure if the limit is 64k or not...
-
Jun 23rd, 2003, 06:20 PM
#6
Thread Starter
New Member
Looks like it's finally working. It finally gets the text! I'm testing the limitations, so far i've been able to get ~94.5k characters (haven't testeted any higher yet) from the IM window. This seems to exceed the supposed limit, so does that limit not apply in .NET? Just curious. I guess I have a couple other questions now that this is working:
Can I detect when a window flashes and then get the handle of that window, or is there a simpler way to detect when you've been IMed and get the window handle to get the text?
You seem to have done some pretty fun stuff with AIM . I've just started to fiddle with it (for my own use). Do you have any source code you could email me? It could really help in learning how to deal with aim.
-
Jun 25th, 2003, 03:10 PM
#7
Fanatic Member
I found that the easiest way to check if I've gotten a new IM is to always keep a record of the text length of each IM using WM_GETTEXTLENGTH. I know I've gotten IM by checking to see if a new window has appeared, or the text length changed for one of the existing windows.
When I looked at my AIM project, it looked a little on the convoluted side, and I never got around to commenting it (I have the bad habit of writing code like crazy and then going back and commenting it while I still remember what it does). Therefore, I don't think I'll post the code, but I will answer as my questions regarding AIM as I can.
-
Dec 1st, 2003, 05:14 PM
#8
Junior Member
I know its an old thread,.. sorry.
Mistame, You said you got EM_STREAMOUT working on a roch text box outside your process space (ie AIM)? would you care to share how?
did you use any type of hooking?
-
Dec 2nd, 2003, 05:29 PM
#9
New Member
Hey, IM me, my screen name is Cubs Anonymous, maybe i can help you out, i know a few places that have this source
\/\The Conscience of a Hacker/\/
by
+++The Mentor+++
Written on January 8, 1986
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<cut by admin -- too long>
-
Dec 2nd, 2003, 05:32 PM
#10
New Member
also, i got an idea if anybody wants to code a 2 person project with me... anybody wanna enhance the IMs? like give them new looks and an auto away program where it switchers your IM? It could also include stuff like an IM logger, and maybe use winsock to play games with persons on AIM?
\/\The Conscience of a Hacker/\/
by
+++The Mentor+++
Written on January 8, 1986
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<cut by admin -- too long>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|