Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-20
4
Medium Priority
?
2,138 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 1500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
Suggested Courses

927 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