Solved

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

Posted on 2004-04-20
4
2,128 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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