473,809 Members | 2,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trapping Windows Messages from other applications

Okay I'm trying to write an application to monitor a running process. Right
now I have a front end which allows the user to pick the programs they want
to monitor. The interval between how often I information for this process,
things like CPU usage, peak memory, virtual memory, etc... All this I get
from System.Diagnost ics.Process. I display this information in a listview and
things are working fine. The user can then select one of these processes
being monitored and "I'll display modules in a treeview to them.

Now the thing I want to also do is display windows messages in a listbox. So
for example say I'm monitoring a program called MyApp.exe. I want to select
this program and then go back to this program and contiue working in it.
Clicking command buttons, entering data, selecting menu options. But I want
all these message to be captured by this monitoring program in that listbox
so when I return to it I would see a windows message for
WM_MOUSEMOVE
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCL K
WM_RBUTTONDOWN
WM_RBUTTONUP
WM_RBUTTONDBLCL K
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MBUTTONDBLCL K
etc...

I will also create another list of what messages I want to capture but first
I need to capture them and can't figure this part out.

--
Joe Pacelli
jo********@eart hlink.net
Nov 17 '05 #1
2 11499
Hi,

For that you will have to P/invoke the win32 API, IIRC the function is
called SetWinEventHook , you will need either the hWnd of the main window or
the process ID of the target process.
Take a look at google groups you will find the answer there,

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Joe Pacelli" <Jo********@dis cussions.micros oft.com> wrote in message
news:16******** *************** ***********@mic rosoft.com...
Okay I'm trying to write an application to monitor a running process.
Right
now I have a front end which allows the user to pick the programs they
want
to monitor. The interval between how often I information for this process,
things like CPU usage, peak memory, virtual memory, etc... All this I get
from System.Diagnost ics.Process. I display this information in a listview
and
things are working fine. The user can then select one of these processes
being monitored and "I'll display modules in a treeview to them.

Now the thing I want to also do is display windows messages in a listbox.
So
for example say I'm monitoring a program called MyApp.exe. I want to
select
this program and then go back to this program and contiue working in it.
Clicking command buttons, entering data, selecting menu options. But I
want
all these message to be captured by this monitoring program in that
listbox
so when I return to it I would see a windows message for
WM_MOUSEMOVE
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCL K
WM_RBUTTONDOWN
WM_RBUTTONUP
WM_RBUTTONDBLCL K
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MBUTTONDBLCL K
etc...

I will also create another list of what messages I want to capture but
first
I need to capture them and can't figure this part out.

--
Joe Pacelli
jo********@eart hlink.net

Nov 17 '05 #2
Joe,

This can be accomplished using the System.Windows. Forms.NativeWin dow
class. See the following example.
using System;
using System.Windows. Forms;

namespace WindowsApplicat ion
{
public class MyHookClass : NativeWindow
{
public MyHookClass(Int Ptr hWnd)
{
// Assign the handle from the source window to this class.
this.AssignHand le(hWnd);
}

protected override void WndProc(ref Message m)
{
const int WM_MOUSEMOVE = 0x0200;

switch (m.Msg)
{
case WM_MOUSEMOVE:
// Do what you need to do.
break;
}

base.WndProc (ref m);
}
}
}
Jason

Joe Pacelli wrote:
Okay I'm trying to write an application to monitor a running process. Right
now I have a front end which allows the user to pick the programs they want
to monitor. The interval between how often I information for this process,
things like CPU usage, peak memory, virtual memory, etc... All this I get
from System.Diagnost ics.Process. I display this information in a listview and
things are working fine. The user can then select one of these processes
being monitored and "I'll display modules in a treeview to them.

Now the thing I want to also do is display windows messages in a listbox. So
for example say I'm monitoring a program called MyApp.exe. I want to select
this program and then go back to this program and contiue working in it.
Clicking command buttons, entering data, selecting menu options. But I want
all these message to be captured by this monitoring program in that listbox
so when I return to it I would see a windows message for
WM_MOUSEMOVE
WM_LBUTTONDOWN
WM_LBUTTONUP
WM_LBUTTONDBLCL K
WM_RBUTTONDOWN
WM_RBUTTONUP
WM_RBUTTONDBLCL K
WM_MBUTTONDOWN
WM_MBUTTONUP
WM_MBUTTONDBLCL K
etc...

I will also create another list of what messages I want to capture but first
I need to capture them and can't figure this part out.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2220
by: Brad Jones | last post by:
Hello, I'm hoping someone can give me some help or guidance here. I'm not sure if this is even the best group to post to for this. Our OEM equipment's software architecture relies heavily on a "master" windows service. This responsibility of this service is to launch 10 or so other applications, some of which have GUI's. These applications need to be running whether somebody is logged in or not. There is no communication required between...
6
4766
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
1
8557
by: timtos | last post by:
When I am looking at custom drawing of controls I often see somthing like this: public enum ReflectedMessages { OCM__BASE = (Msg.WM_USER+0x1c00), OCM_COMMAND = (OCM__BASE + Msg.WM_COMMAND), OCM_CTLCOLORBTN = (OCM__BASE + Msg.WM_CTLCOLORBTN), ... }
2
4941
by: Mr Sparkles | last post by:
Heya Everyone, I am currently creating an application audit system that will log how much use an application will be used by employees of my company, and the type of features they use...so I wanted to have a .NET program or service running in the background that would log what actions they perform in specified applications and update our main database...but I am running into problems trapping the events of when people click on buttons...
1
5694
by: Artur Kowalski | last post by:
I have a NotifyIcon in my Windows Service project and I am trying to add a ContextMenu to this NotifyIcon or use some of the mouse events. Everything isn't working. I think so base class of the service System.ServiceProcess.ServiceBase don't catchWindows messages like mouse or timer messages. Any Idea? Thanks,
14
4920
by: Brian Keating EI9FXB | last post by:
I wonder can anyone reccomment a solution to this problem. Let me explain, I've services running on my system, my application receives diagnostic messages from these services, what i want to do is create an MDIChild window for each service that is sending messages. Ok so far so good, but I get problems if one service is constantly sending messages to it's window because, this window is very busy updating it's view, hence because it's...
14
4113
by: | last post by:
Hi All, I am little confused here, hope you can help me. While processing WM_POWERBROADCAST (wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy operation(30 sec) before system Suspends or hibernates. To achieve this, in my message handler when processing PBT_APMQUERYSUSPEND, I create another thread which takes care of making this lengthy operation, and when its done I
3
7490
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work on her local machine. Everything looks pretty good. OpenLDAP/cygwin works great. PostgreSQL works great. Apache runs. PHP runs. But when I try to connect to my PostgreSQL server using PHPPgAdmin, I
4
10519
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it doesn't seem to write to the screen in the way I would expect. The output is:
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.