Solved

How to capture "Net Send" messages from Windows Messenger?

Posted on 2004-04-20
4
2,118 Views
Last Modified: 2010-05-18
Just need to capture messages coming to the user on whose system the VB program is running.  I do not need to capture messages on the entire network.

VB.NET example preferred but VB6 is ok.

Thanks for any ideas.
0
Comment
Question by:mistert006
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 500 total points
ID: 10871649
This is in VB6. Try adding a Listbox and a timer.Set the Timer interval to 1000.


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Const BM_CLICK = &HF5
Const WM_GETTEXTLENGTH = &HE
Private Const WM_GETTEXT = &HD

Private Sub Timer1_Timer()
Dim lWin As Long
Dim Control As Long
Dim text As String
Dim textlen As Long
lWin = FindWindow(vbNullString, "Messenger Service ")
If lWin <> 0 Then
  Control = FindWindowEx(lWin, 0, "Static", vbNullString)
      textlen = SendMessage(Control, WM_GETTEXTLENGTH, vbNull, vbNull)
      textlen = textlen + 1
  text = Space$(textlen)
  Call SendMessage(Control&, WM_GETTEXT, textlen, ByVal text)
 
  Control = FindWindowEx(lWin, 0, "Button", vbNullString)
  SendMessage Control, BM_CLICK, 0, 0
  List1.AddItem text
End If
End Sub
0
 

Author Comment

by:mistert006
ID: 10878129
I tried the program.  It does work, but I would still see the message box flash on the screen.  I would like to intercept the message so the message box from Windows Messenger service is not displayed at all.

Thank you very much.
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 10888826
You could try lowering the timer interval,but I think you might still see the message flash.I've never seen anyone successfully intercept the message box before it appears using VB.I think you would need to create a hook using a DLL written in a language like C to accomplish this.

Good Luck.
0
 

Expert Comment

by:hello_2004
ID: 11691257
I have tried the code.. it works wonderful.. but it doesn't read the other window messages specifically those that have information icon (i.e. i inside a triangle)  in it.

How to read the tetx from such a message box.

Please help I will award points for this......

Regards
Hello_2004
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA color chart bars 12 78
Spell Check in VB6 13 99
Help me. 3 46
Child Form in front 4 39
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now