473,385 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 5678

"Will Pittenger" <wi************@verizon.net> wrote in message
news:ue**************@TK2MSFTNGP09.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.4M.austin.rr.com> wrote in message
news:tG**********************@twister.austin.rr.co m...

"Will Pittenger" <wi************@verizon.net> wrote in message
news:ue**************@TK2MSFTNGP09.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.4M.austin.rr.com> wrote in message
news:tG**********************@twister.austin.rr.co m...

"Will Pittenger" <wi************@verizon.net> wrote in message
news:ue**************@TK2MSFTNGP09.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****************@TK2MSFTNGP09.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**************@TK2MSFTNGP12.phx.gbl...
"Will Pittenger" <wi************@verizon.net> wrote in message
news:%2****************@TK2MSFTNGP09.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.4M.austin.rr.com> wrote in message
news:cm*********************@twister.austin.rr.com ...

"Will Pittenger" <wi************@verizon.net> wrote in message
news:ef**************@TK2MSFTNGP12.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**************@TK2MSFTNGP09.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.4M.austin.rr.com> wrote in message
news:cm*********************@twister.austin.rr.com ...

"Will Pittenger" <wi************@verizon.net> wrote in message
news:ef**************@TK2MSFTNGP12.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.4M.austin.rr.com> wrote in message
news:Cb*********************@twister.austin.rr.com ...

"Will Pittenger" <wi************@verizon.net> wrote in message
news:eG**************@TK2MSFTNGP09.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.4M.austin.rr.com> wrote in message
news:cm*********************@twister.austin.rr.com ...

"Will Pittenger" <wi************@verizon.net> wrote in message
news:ef**************@TK2MSFTNGP12.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******************@TK2MSFTNGP09.phx.gbl...
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.4M.austin.rr.com> wrote in message
news:Cb*********************@twister.austin.rr.com ...

"Will Pittenger" <wi************@verizon.net> wrote in message
news:eG**************@TK2MSFTNGP09.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.4M.austin.rr.com> wrote in message
news:cm*********************@twister.austin.rr.com ...
>
> "Will Pittenger" <wi************@verizon.net> wrote in message
> news:ef**************@TK2MSFTNGP12.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
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...
4
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...
5
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...
6
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...
16
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...
18
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...
8
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...
4
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.