473,407 Members | 2,312 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,407 software developers and data experts.

handling key events

hi,

does anybody know, how to handle keyboard events on system level (i need to
be able to do some action, when keyboard shortcut is pressed, even if my
application isn't active),

thanks for replies (sorry for my english, i'm working on it)
Nov 16 '05 #1
3 1772
Roman Maček wrote:
does anybody know, how to handle keyboard events on system level (i
system-level = device-driver !?
need to be able to do some action, when keyboard shortcut is pressed,
even if my application isn't active),


Use "SetWindowsHookEx"

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

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/
Nov 16 '05 #2
Jochen Kalmbach wrote:
need to be able to do some action, when keyboard shortcut is pressed,
even if my application isn't active),


Use "SetWindowsHookEx"

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


I forgot to mention:
System-Wide hooks are not supported in C#. You have to use C/C++

See:
http://www.pinvoke.net/default.aspx/...tWindowsHookEx
--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/
Nov 16 '05 #3
Hi Jochen,
I forgot to mention:
System-Wide hooks are not supported in C#. You have to use C/C++
This is true and is not true at the same time.
Maybe all programmers tried to implement windows hooks end up reading this
Global Hook Is Not Supported in .NET Framework
in the MS KB. Yes this is true. Global hooks are not supported beacuse of
the way they work. However there 2 exceptions of that and MS should've
mentioned them
The exceptions are: WH_MOUSE_LL and WH_KEYBOARD_LL. They are different from
the other global hooks because of the following statement:
MSDN:
"However, the WH_KEYBOARD_LL / WH_MOUSE_LL hook is not injected into another
process"

As far as I understand Roman needs WH_KEYBOARD_LL and this is possible to be
written in C#. Ofcourse PInvoke has to be used for calling SetWindowsHookEx
API.

How to do it I don't have an example nor link about it right now. But such
examples are all over the net. Just poll google and there are tons of
examples, I believe.
--
HTH
B\rgds
Stoitcho Goutsev (100) [C# MVP]


See:
http://www.pinvoke.net/default.aspx/...tWindowsHookEx
--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/

Nov 16 '05 #4

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

Similar topics

2
by: Marinos Christoforou | last post by:
Sorry if this has been asked before but as an inexperienced wanna-be C# programmer I wondering how to code classes to help build a standard Windows UI. For example to build a common toolbar. I...
2
by: Eric Newton | last post by:
VB's more declarative nature of handling events is golden. I'm hoping C# will acquire this type of deal, in addition to the anonymous delegates. could do same as vb (actually would be easier to...
4
by: hillcountry74 | last post by:
Hi, I'm a newbie and trying to understand event handling in c#. I have understood handling events using delelgate objects. But not this method- "Event handling by overriding the virtual...
3
by: Ashok Kumar K | last post by:
Hi all, Where can I get some insight on using the __hook, __unhook, event_source and event_receiver for specifically COM events. The documentation given in MSDN is very minimal. I have the...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
9
by: Sridhar | last post by:
Hi, I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control...
2
by: Paul E. Orman | last post by:
I have a piece of VB code (.NET 1.1 - VB 2003) that loads data from a database through a timer. So the timer is setup and from it I call the procedure that loads the latest records from the...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
2
by: Jordan | last post by:
I need to handle UI events in a worker thread instead of the primary UI thread. In C#, is the normal UI event handling behavior to run in a context thread on the thread pool or are events always...
35
by: jeffc226 | last post by:
I'm interested in an idiom for handling errors in functions without using traditional nested ifs, because I think that can be very awkward and difficult to maintain, when the number of error checks...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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,...
0
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...

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.