473,768 Members | 7,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to track the mouse without capturing it?

If I were writing a C++ program, I would write a mouse hook. Does C# and
..NET 1.1 have anything equivalent. If not, I suppose I will need to use the
Win32 API.
----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
Nov 15 '05 #1
9 5727

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:ue******** ******@TK2MSFTN GP09.phx.gbl...
If I were writing a C++ program, I would write a mouse hook. Does C# and .NET 1.1 have anything equivalent. If not, I suppose I will need to use the Win32 API.


A 5-second Google search revealed:
http://support.microsoft.com/?kbid=318804

;)

-C

P.S. - nothing personal, I do the same thing sometimes
and people give me crap about it all the time, I'm just
spreading the sarcasm a little :)
Nov 15 '05 #2
so... is "spreading it" supposed to somehow ameliorate
"the crap", or is this revenge?

;o)
--
Grace + Peace,
Peter N Roth
Engineering Objects International
http://engineeringobjects.com
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:tG******** **************@ twister.austin. rr.com...

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:ue******** ******@TK2MSFTN GP09.phx.gbl...
If I were writing a C++ program, I would write a mouse hook. Does C#

and
.NET 1.1 have anything equivalent. If not, I suppose I will need to

use the
Win32 API.


A 5-second Google search revealed:
http://support.microsoft.com/?kbid=318804

;)

-C

P.S. - nothing personal, I do the same thing sometimes
and people give me crap about it all the time, I'm just
spreading the sarcasm a little :)

Nov 15 '05 #3
Not only does it cover hooks, but it does so with the mouse hook. Still, I
was hoping that somewhere there was a .NET event which did the hook for
you..
----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:tG******** **************@ twister.austin. rr.com...

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:ue******** ******@TK2MSFTN GP09.phx.gbl...
If I were writing a C++ program, I would write a mouse hook. Does C#

and
.NET 1.1 have anything equivalent. If not, I suppose I will need to

use the
Win32 API.


A 5-second Google search revealed:
http://support.microsoft.com/?kbid=318804

;)

-C

P.S. - nothing personal, I do the same thing sometimes
and people give me crap about it all the time, I'm just
spreading the sarcasm a little :)

Nov 15 '05 #4
"Will Pittenger" <wi************ @verizon.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Not only does it cover hooks, but it does so with the mouse hook. Still, I was hoping that somewhere there was a .NET event which did the hook for
you..


if you want to hook only your app messages you should use the IMessageFilter
else use the above which is a system hook
Nov 15 '05 #5
No, I need something global.
----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"ncaHammer" <nc*******@nos. pamhot.mail.com > wrote in message
news:O4******** ******@TK2MSFTN GP12.phx.gbl...
"Will Pittenger" <wi************ @verizon.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Not only does it cover hooks, but it does so with the mouse hook.
Still, I
was hoping that somewhere there was a .NET event which did the hook for
you..
if you want to hook only your app messages you should use the

IMessageFilter else use the above which is a system hook

Nov 15 '05 #6
Well the code that I wrote was based on the article that you pointed me to.
And as I noted, I used Word to help OE. Can a MEC++ DLL be written with out
VC++.NET? All I have is VC# Standard. It sounds like with .NET, if you
want the professional compilers, you MUST buy the entire studio. I do not
have that kind of money.
----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:cm******** *************@t wister.austin.r r.com...

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:ef******** ******@TK2MSFTN GP12.phx.gbl...
Ok. I now have the code below. This class is intended to hide the

hook
concept. The owner sees a C# event --- sort of anyway. The event

itself is
private so I could implement On and Off functions. Instead the owner

passes
its caller to the tracker's consturctor. The problem is that my hook
handler is never called. I have verified that mouseTrack.on is

called, but
onHook (at the bottom) is never called. Could someone tell me what is
wrong?


Hrm, I know that certain global hooks are impossible from .NET. I know
you cannot set global keyboard handlers (like for CTRL+ALT+DEL, etc)
in .NET. It's *possible*, but I"m not sure, that this same limitation
exists for mouse hooks.

For global hooks, you have to have a DLL that has at least one
export method and you must pass that export method to the global hook.
Windows will load your DLL into it's process space and call your export
function. I think that it will be in a different process space, so you
can't do everything in one process. I may be wrong on that last part.

Anyhow, you cannot create old C-style DLL exports with .NET unless
you have a small MEC++ wrapper for your .NET assembly.
BTW: When I pasted my code from VS.NET 2003 into Outlook Express 6,

all
indentation was lost and all lines were triple spaced -- even though

OE is
using plain text for newsgroup messages (all font colors remain,

including
the backgrounds). I had to copy this text into Word 2002 and copy

that to
the message. If someone knows why OE does not take the plain text

version
of what is on the clipboard rather than the RTF version, I would be
grateful.


Yeah, OE is not the greatest newsread. It uses a rich text box which
is always capable of receiving colored text, so even if it's in
"plain text" mode, it'll still receive the colors. When you actually
post, it'll remove the colorization.

Unfortunately, I don't think there's a way to preserve the formatting.
You might try a text editor like EditPlus or TextPad. Paste into
there and then copy from there and paste into OE. Sometimes that
works.

<SNIP code>

-c

Nov 15 '05 #7

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:eG******** ******@TK2MSFTN GP09.phx.gbl...
Well the code that I wrote was based on the article that you pointed me to. And as I noted, I used Word to help OE. Can a MEC++ DLL be written with out VC++.NET? All I have is VC# Standard. It sounds like with .NET, if you want the professional compilers, you MUST buy the entire studio. I do not have that kind of money.
You can write .NET code in notepad if you want.

Well, I thought that a MEC++ compiler came with the .NET Framework
SDK, but I can't seem to find it, so I must be wrong :(

As far as the other compilers, you don't need VS.NET 2003.

The .NET Framework SDK (free) comes with a C# compiler,
a VB.NET compiler and a JScript.NET compiler, as well as
an IL compiler and an assembly linker. All free.

Shoulda got VC++.NET and then used SharpDevelop or something :(

-c

----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:cm******** *************@t wister.austin.r r.com...

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:ef******** ******@TK2MSFTN GP12.phx.gbl...
Ok. I now have the code below. This class is intended to hide the
hook
concept. The owner sees a C# event --- sort of anyway. The event

itself is
private so I could implement On and Off functions. Instead the
owner passes
its caller to the tracker's consturctor. The problem is that my
hook handler is never called. I have verified that mouseTrack.on is

called, but
onHook (at the bottom) is never called. Could someone tell me what is wrong?


Hrm, I know that certain global hooks are impossible from .NET. I

know you cannot set global keyboard handlers (like for CTRL+ALT+DEL, etc)
in .NET. It's *possible*, but I"m not sure, that this same limitation exists for mouse hooks.

For global hooks, you have to have a DLL that has at least one
export method and you must pass that export method to the global hook. Windows will load your DLL into it's process space and call your export function. I think that it will be in a different process space, so you can't do everything in one process. I may be wrong on that last part.
Anyhow, you cannot create old C-style DLL exports with .NET unless
you have a small MEC++ wrapper for your .NET assembly.
BTW: When I pasted my code from VS.NET 2003 into Outlook Express 6,
all
indentation was lost and all lines were triple spaced -- even
though OE is
using plain text for newsgroup messages (all font colors remain,

including
the backgrounds). I had to copy this text into Word 2002 and copy

that to
the message. If someone knows why OE does not take the plain text

version
of what is on the clipboard rather than the RTF version, I would
be grateful.


Yeah, OE is not the greatest newsread. It uses a rich text box which
is always capable of receiving colored text, so even if it's in
"plain text" mode, it'll still receive the colors. When you actually
post, it'll remove the colorization.

Unfortunately, I don't think there's a way to preserve the

formatting. You might try a text editor like EditPlus or TextPad. Paste into
there and then copy from there and paste into OE. Sometimes that
works.

<SNIP code>

-c


Nov 15 '05 #8
If you look at the more recent thread where someone is asking which C# to
get, you will find that the main reason I got the book that I did was that
it came with C# (a $100 value), but cost only $79. Where do your deals come
from?
----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:Cb******** *************@t wister.austin.r r.com...

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:eG******** ******@TK2MSFTN GP09.phx.gbl...
Well the code that I wrote was based on the article that you pointed

me to.
And as I noted, I used Word to help OE. Can a MEC++ DLL be written

with out
VC++.NET? All I have is VC# Standard. It sounds like with .NET, if

you
want the professional compilers, you MUST buy the entire studio. I do

not
have that kind of money.


You can write .NET code in notepad if you want.

Well, I thought that a MEC++ compiler came with the .NET Framework
SDK, but I can't seem to find it, so I must be wrong :(

As far as the other compilers, you don't need VS.NET 2003.

The .NET Framework SDK (free) comes with a C# compiler,
a VB.NET compiler and a JScript.NET compiler, as well as
an IL compiler and an assembly linker. All free.

Shoulda got VC++.NET and then used SharpDevelop or something :(

-c

----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:cm******** *************@t wister.austin.r r.com...

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:ef******** ******@TK2MSFTN GP12.phx.gbl...
> Ok. I now have the code below. This class is intended to hide the hook
> concept. The owner sees a C# event --- sort of anyway. The event
itself is
> private so I could implement On and Off functions. Instead the owner passes
> its caller to the tracker's consturctor. The problem is that my hook > handler is never called. I have verified that mouseTrack.on is
called, but
> onHook (at the bottom) is never called. Could someone tell me what is > wrong?

Hrm, I know that certain global hooks are impossible from .NET. I know you cannot set global keyboard handlers (like for CTRL+ALT+DEL, etc)
in .NET. It's *possible*, but I"m not sure, that this same limitation exists for mouse hooks.

For global hooks, you have to have a DLL that has at least one
export method and you must pass that export method to the global hook. Windows will load your DLL into it's process space and call your export function. I think that it will be in a different process space, so you can't do everything in one process. I may be wrong on that last part.
Anyhow, you cannot create old C-style DLL exports with .NET unless
you have a small MEC++ wrapper for your .NET assembly.

> BTW: When I pasted my code from VS.NET 2003 into Outlook Express 6, all
> indentation was lost and all lines were triple spaced -- even though OE is
> using plain text for newsgroup messages (all font colors remain,
including
> the backgrounds). I had to copy this text into Word 2002 and copy
that to
> the message. If someone knows why OE does not take the plain text
version
> of what is on the clipboard rather than the RTF version, I would be > grateful.

Yeah, OE is not the greatest newsread. It uses a rich text box which
is always capable of receiving colored text, so even if it's in
"plain text" mode, it'll still receive the colors. When you actually
post, it'll remove the colorization.

Unfortunately, I don't think there's a way to preserve the formatting. You might try a text editor like EditPlus or TextPad. Paste into
there and then copy from there and paste into OE. Sometimes that
works.

<SNIP code>

-c



Nov 15 '05 #9
MSDN Subscriptions :)

I've always been fortunate enough to work for companies
with enough MSDN subscriptions for me to legally have a copy
of VS.NET on my laptop for work or whatnot.

-c

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
If you look at the more recent thread where someone is asking which C# to get, you will find that the main reason I got the book that I did was that it came with C# (a $100 value), but cost only $79. Where do your deals come from?
----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:Cb******** *************@t wister.austin.r r.com...

"Will Pittenger" <wi************ @verizon.net> wrote in message
news:eG******** ******@TK2MSFTN GP09.phx.gbl...
Well the code that I wrote was based on the article that you pointed
me to.
And as I noted, I used Word to help OE. Can a MEC++ DLL be
written with out
VC++.NET? All I have is VC# Standard. It sounds like with .NET,
if you
want the professional compilers, you MUST buy the entire studio.
I do not
have that kind of money.


You can write .NET code in notepad if you want.

Well, I thought that a MEC++ compiler came with the .NET Framework
SDK, but I can't seem to find it, so I must be wrong :(

As far as the other compilers, you don't need VS.NET 2003.

The .NET Framework SDK (free) comes with a C# compiler,
a VB.NET compiler and a JScript.NET compiler, as well as
an IL compiler and an assembly linker. All free.

Shoulda got VC++.NET and then used SharpDevelop or something :(

-c

----------
Will Pittenger
E-Mail: mailto:wi****** ******@verizon. net
All mail filtered by Qurb (www.qurb.com)
"Chad Myers" <cm****@N0.SP.4 M.austin.rr.com > wrote in message
news:cm******** *************@t wister.austin.r r.com...
>
> "Will Pittenger" <wi************ @verizon.net> wrote in message
> news:ef******** ******@TK2MSFTN GP12.phx.gbl...
> > Ok. I now have the code below. This class is intended to
hide the
> hook
> > concept. The owner sees a C# event --- sort of anyway. The
event > itself is
> > private so I could implement On and Off functions. Instead the owner
> passes
> > its caller to the tracker's consturctor. The problem is that
my hook
> > handler is never called. I have verified that mouseTrack.on
is > called, but
> > onHook (at the bottom) is never called. Could someone tell me

what is
> > wrong?
>
> Hrm, I know that certain global hooks are impossible from .NET. I know
> you cannot set global keyboard handlers (like for CTRL+ALT+DEL,
etc) > in .NET. It's *possible*, but I"m not sure, that this same

limitation
> exists for mouse hooks.
>
> For global hooks, you have to have a DLL that has at least one
> export method and you must pass that export method to the global

hook.
> Windows will load your DLL into it's process space and call your

export
> function. I think that it will be in a different process space, so you
> can't do everything in one process. I may be wrong on that last

part.
>
> Anyhow, you cannot create old C-style DLL exports with .NET
unless > you have a small MEC++ wrapper for your .NET assembly.
>
> > BTW: When I pasted my code from VS.NET 2003 into Outlook Express 6,
> all
> > indentation was lost and all lines were triple spaced -- even

though
> OE is
> > using plain text for newsgroup messages (all font colors
remain, > including
> > the backgrounds). I had to copy this text into Word 2002 and copy > that to
> > the message. If someone knows why OE does not take the plain text > version
> > of what is on the clipboard rather than the RTF version, I would be
> > grateful.
>
> Yeah, OE is not the greatest newsread. It uses a rich text box

which > is always capable of receiving colored text, so even if it's in
> "plain text" mode, it'll still receive the colors. When you actually > post, it'll remove the colorization.
>
> Unfortunately, I don't think there's a way to preserve the

formatting.
> You might try a text editor like EditPlus or TextPad. Paste into
> there and then copy from there and paste into OE. Sometimes that
> works.
>
> <SNIP code>
>
> -c
>
>



Nov 15 '05 #10

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

Similar topics

2
6546
by: Evgeny Zoldin | last post by:
Hi, ALL Does anybody know how to capture mouse wheel events in C# occured on the control that natively does not suppot them (e.g. MS Flex Grid)? I have code hooks windows messages in VB6. I've translated it into C#, but it does not work :-( Any another idea? Thanks
4
14728
by: Jay | last post by:
Hi, How can I capture mouse position on Image? I found number of script capturing mouse position of the page. But I could not find anything based on image. What I want to find out is X Y coordinates of mouse position. based on left of the top of my image is 0 0 (X Y coordinates) otherwise, I need to find out position of my image so I can calculate.
5
4746
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event gets triggered and the double click is not identified at all. Is there any way I can invoke the double click when the mouse move also exists?
6
8769
by: Ahmed | last post by:
Hi, I am trying to capture the mouse events when the user clicks on the desktop not the winform. I looked at the mouse_event function but MSDN documentation says that it is suppressed in win NT/2000/XP. What I am trying to do is to get print screen for a section on the desktop every number of seconds. And I want the user to be able to select that region. Any help will be appreciated.
16
10937
by: dfaber | last post by:
Hi all, I have been searching for a keyboard and mouse tracker on linux. I've read solutions (watch at sourceforge) which look at /proc/interrupts to check keyboard or mouse activity. I also read one post where "watch" seems to have difficulty tracking usb keyboards and mice. So, I'm out of ideas here. My goal are: 1. Check keyboard activity. I'm not interested in logging which keys are pressed or record them.
18
22115
by: eliss.carmine | last post by:
Is it possible to simulate a mouse click in the window I made (it's a Form), but not give it focus? I tried using WinAPI's mouseevent and SendMessage of WM_LBUTTONDOWN/WM_LBUTTONUP as suggested by the folks in #winapi on EFnet, but I think those require the window to have focus. Either that, or I'm doing something else wrong. The click actually seems to work once, and then stops working... I have no idea what is the problem actually....
8
2742
by: Ron Eggler | last post by:
Hi, I would like to get the time of the most recent human activity like a cursor movement or a key hit. Does anyone know how I can get this back to start some action after there has been no activity for X minutes/seconds? Thank you! -- chEErs roN
4
6976
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I just gotta fix it. I need to make some calculations on the measurements and VB6 is my language. Yes, the system mouse will corrupt the measurement, but it's an auditing function and that's acceptable.
4
3518
by: mbatestblrock | last post by:
I hope this makes some sense. My ultimate goal here is to execute a block of code if the mouse has not moved in a minute or so within the broswer. The machine I am running this on is for internal use only, so I have no fear of this not working in certain browsers, etc. I am no javascript pro but know enough to catch on if anyone is kind enough to help me out here. One of the only ways I could see this working is by having js check the...
0
9576
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
10175
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10017
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
9961
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,...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6656
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
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3932
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.