469,573 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Detecting a Mouse click from a windows service

Is it possible to detect a mouse click from a .net service. I want a process
running in the background that will detect when the user clicks the mouse
button (anywhere on the screen) and executes an action accordingly.
All the event handlers for the mouse that I see are for Windows Forms. Is
there a way to do it without any controls on the screen?

Thanks
Nov 1 '05 #1
2 4354
If you where using mfc c++ you would do it trough windows hooks.

Start with reading this article about system wide hooks in MFC.
http://www.codeguru.com/Cpp/COM-Tech...cle.php/c4509/

Best regards Björn Olsson
Head of Technology
Centre for Business Solutions
Gothenburg School of Economics and Commercial Law
University of Göteborg
Department of Business and Administration
PO BOX 610
SE-405 30 Gothenburg Sweden
P: +46317732767
C: +46708630872
F: +46317734754
"Benoit Martin" wrote:
Is it possible to detect a mouse click from a .net service. I want a process
running in the background that will detect when the user clicks the mouse
button (anywhere on the screen) and executes an action accordingly.
All the event handlers for the mouse that I see are for Windows Forms. Is
there a way to do it without any controls on the screen?

Thanks

Nov 2 '05 #2
A service has no concept of user interface, thus click events are pointless
to it. You can however allow it to interact with the desktop, but its
cumbersome.

See this thread.
http://groups.google.co.uk/group/mic...6e24000f87a629

Its definatelyt nor recommened in a .net service. If I was developing this
I would create a small desktop application to listen for clicks, and
communciate them to the listening service via a socket call. One other
thing - youre talking about a global event hook and thats highly processor
and resource hungry.

http://www.codeproject.com/csharp/globalhook.asp

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"Benoit Martin" <be****@digitalmediums.com> wrote in message
news:eW*************@TK2MSFTNGP10.phx.gbl...
Is it possible to detect a mouse click from a .net service. I want a
process running in the background that will detect when the user clicks
the mouse button (anywhere on the screen) and executes an action
accordingly.
All the event handlers for the mouse that I see are for Windows Forms. Is
there a way to do it without any controls on the screen?

Thanks

Nov 2 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by BadOmen | last post: by
reply views Thread by Chris Mullins | last post: by
2 posts views Thread by Benoit Martin | last post: by
3 posts views Thread by Morten Snedker | last post: by
1 post views Thread by Przemek M. Zawada | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.