PC Review


Reply
Thread Tools Rate Thread

Can C# listen for system events?

 
 
Alex
Guest
Posts: n/a
 
      21st Aug 2003
I am trying to determine if C# has the capabilities to listen for system
events when the application does not have the window's focus.

I am writing a windows application that I would like to run in the
background when I am using my computer. I would like this windows
application to utilize the clipboard, and determine when data has changed on
the clipboard. I would also like my app to listen for Ctrl+C and Ctrl+V
events, as well as mouse copy/paste events.

What I have be able to explore so far is that I can write an app that will
listen for keyboard events when the application has window's focus. I cannot
seem to find any information on if it is possible to listen to events when
the window does not have focus.

Can anyone provide insight to help me out? Preferably C# code if it's
possible. Is this solution possible with the C# language?

Thanks,

Alex


 
Reply With Quote
 
 
 
 
Tian Min Huang
Guest
Posts: n/a
 
      22nd Aug 2003
Hi Yanhong,

I believe that Alex should implement Global Hook instead of the one
associated to a specific thread. However, Microsoft .NET Framework does not
support Global Hook. That is, we are not able to use C# to implement it.
The KB article 318804 discusses this issue in detail:

HOW TO: Set a Windows Hook in Visual C# .NET
http://support.microsoft.com/?kbid=318804

"You cannot implement global hooks in Microsoft .NET Framework. To install
a global hook, a hook must have a native dynamic-link library (DLL) export
to inject itself in another process that requires a valid, consistent
function to call into. This requires a DLL export, which .NET Framework
does not support. Managed code has no concept of a consistent value for a
function pointer because these function pointers are proxies that are built
dynamically."

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided Ħ°as isĦħ with no warranties and confers no rights.


 
Reply With Quote
 
Ross Donald
Guest
Posts: n/a
 
      22nd Aug 2003
Hi Alex,

You can do this in C# but you have to use the Win32 API. The
SetClipboardViewer() function can be used to register your application for
notifications of clipboard changes.

I have an article and an example in C# on my site that goes into more
detail.

http://www.radsoftware.com.au/web/CodeZone

--
Ross Donald
http://www.radsoftware.com.au/web/WebLog/

"Alex" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am trying to determine if C# has the capabilities to listen for system
> events when the application does not have the window's focus.
>
> I am writing a windows application that I would like to run in the
> background when I am using my computer. I would like this windows
> application to utilize the clipboard, and determine when data has changed

on
> the clipboard. I would also like my app to listen for Ctrl+C and Ctrl+V
> events, as well as mouse copy/paste events.
>
> What I have be able to explore so far is that I can write an app that will
> listen for keyboard events when the application has window's focus. I

cannot
> seem to find any information on if it is possible to listen to events when
> the window does not have focus.
>
> Can anyone provide insight to help me out? Preferably C# code if it's
> possible. Is this solution possible with the C# language?
>
> Thanks,
>
> Alex
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listen to changes volume events? Magnus O. Microsoft C# .NET 0 9th Dec 2006 04:20 PM
Listen for form events...... Alex Stevens Microsoft Dot NET 1 2nd Jul 2004 10:36 AM
Can C# listen for system events? Alex Microsoft Dot NET 2 22nd Aug 2003 04:58 PM
Can C# listen for system events? Alex Microsoft C# .NET 4 22nd Aug 2003 04:58 PM
listen for file system events Abraham Luna \(Attilanet.com\) Microsoft Windows 2000 File System 2 19th Aug 2003 02:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:23 PM.