5,317,180 members and growing! (22,839 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Intermediate

System Hotkey Component

By Alexander Werner

handling a System-wide Hotkey
C#, Windows, .NET 1.0, .NETVisual Studio, VS.NET2002, Dev

Posted: 16 Oct 2002
Updated: 16 Oct 2002
Views: 83,999
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
23 votes for this Article.
Popularity: 5.61 Rating: 4.12 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
8 votes, 38.1%
4
13 votes, 61.9%
5

Introduction

SystemHotkey is a simple component providing a wrapper for RegisterHotkey / UnregisterHotkey Win32-Api functions. The component creates a window which listen for WM_HOTKEY messages.

This shows the code inserted by Windows Forms Designer:

private void InitializeComponent()
{
    this.components = new System.ComponentModel.Container();
    this.systemHotkey1 = new CodeProject.SystemHotkey.SystemHotkey(
           this.components);
    this.label1 = new System.Windows.Forms.Label();
    this.label2 = new System.Windows.Forms.Label();
    this.SuspendLayout();
    // 

    // systemHotkey1

    // 

    this.systemHotkey1.Shortcut = System.Windows.Forms.Shortcut.AltF6;
    this.systemHotkey1.Pressed += new System.EventHandler(
           this.systemHotkey1_Pressed);

The Shortcut property sets the Hotkey and activates it. When the Hotkey is pressed the Pressed event is fired. The Hotkey is automaticaly unregistered at Dispose()

You can use this Component with a Tray-Application which activates when a Hotkey is pressed. The files Systemhotkey.cs and win32.cs should be included in a class-library

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Alexander Werner



Occupation: Web Developer
Location: Germany Germany

Other popular Miscellaneous articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 32 (Total in Forum: 32) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralDon't power off or restart the PCmemberkriegsmar12:11 1 Jun '07  
GeneralVista bug?memberETL .Net15:26 28 Mar '07  
GeneralUsing Windows as a modifier key?memberKbirger4:17 20 Oct '06  
GeneralPlease fix multiple Mod key selectionmembercountryBumkin10:13 15 Jun '06  
GeneralCan you add event KeyDown and KeyUp Please!memberndphuong2:29 4 May '06  
GeneralRe: Can you add event KeyDown and KeyUp Please!memberKbirger4:15 20 Oct '06  
Questionwhere are the numbers coming from?memberjhazlett18:03 8 Mar '06  
AnswerRe: where are the numbers coming from?memberAlexander Werner23:07 8 Mar '06  
GeneralBinding Hotkey in real timememberMarkclee13:40 3 Nov '05  
GeneralRe: Binding Hotkey in real timememberSkoobie Du3:38 26 Jun '07  
GeneralDefault functionality of mapped hotkeymembermakasili11:45 27 Oct '05  
GeneralRe: Default functionality of mapped hotkeymemberSkoobie Du3:19 26 Jun '07  
GeneralOn lost focus - Hotkeys should get unregisteredmembersona_zar2:22 25 Aug '05  
GeneralRe: On lost focus - Hotkeys should get unregisteredmemberAlexander Werner2:47 25 Aug '05  
GeneralRe: On lost focus - Hotkeys should get unregisteredmembersona_zar4:42 25 Aug '05  
GeneralRe: On lost focus - Hotkeys should get unregisteredmembersona_zar5:25 25 Aug '05  
GeneralRe: On lost focus - Hotkeys should get unregisteredmemberSkoobie Du2:59 26 Jun '07  
GeneralRe: On lost focus - Hotkeys should get unregisteredmemberekb021111:52 6 Jul '07  
GeneralUpdate to RegisterHotKey methodsussRick Hobbs @ NeoWorks1:47 24 Sep '04  
GeneralRe: Update to RegisterHotKey methodmembertimbits21420:29 10 Dec '04  
GeneralRe: Update to RegisterHotKey methodmembertimbits21413:13 11 Dec '04  
GeneralRe: Update to RegisterHotKey methodmemberXaroth1:22 18 May '06  
GeneralRe: Update to RegisterHotKey methodmembercountryBumkin10:11 15 Jun '06  
GeneralRe: Update to RegisterHotKey methodmemberolveram715:36 30 Jun '06  
GeneralDoes not work with Win98?sussT. Rumland (tr_cr)14:30 11 Nov '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 Oct 2002
Editor: Nishant Sivakumar
Copyright 2002 by Alexander Werner
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project