Solved

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

Posted on 2004-04-20
4
2,115 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

12 Experts available now in Live!

Get 1:1 Help Now