Click here to Skip to main content
Click here to Skip to main content

System Hotkey Component

By , 16 Oct 2002
Rate this:
Please Sign up or sign in to vote.

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
Web Developer
Germany Germany
No Biography provided

Comments and Discussions

 
QuestionLicense or Terms Of Use? PinmemberChristopJB14-Oct-08 12:19 
GeneralDon't power off or restart the PC Pinmemberkriegsmar1-Jun-07 11:11 
QuestionVista bug? PinmemberETL .Net28-Mar-07 14:26 
QuestionUsing Windows as a modifier key? PinmemberKbirger20-Oct-06 3:17 
GeneralPlease fix multiple Mod key selection PinmembercountryBumkin15-Jun-06 9:13 
QuestionCan you add event KeyDown and KeyUp Please! Pinmemberndphuong4-May-06 1:29 
AnswerRe: Can you add event KeyDown and KeyUp Please! PinmemberKbirger20-Oct-06 3:15 
Questionwhere are the numbers coming from? Pinmemberjhazlett8-Mar-06 17:03 
AnswerRe: where are the numbers coming from? PinmemberAlexander Werner8-Mar-06 22:07 
GeneralBinding Hotkey in real time PinmemberMarkclee3-Nov-05 12:40 
GeneralRe: Binding Hotkey in real time PinmemberSkoobie Du26-Jun-07 2:38 
GeneralDefault functionality of mapped hotkey Pinmembermakasili27-Oct-05 10:45 
GeneralRe: Default functionality of mapped hotkey PinmemberSkoobie Du26-Jun-07 2:19 
GeneralOn lost focus - Hotkeys should get unregistered Pinmembersona_zar25-Aug-05 1:22 
GeneralRe: On lost focus - Hotkeys should get unregistered PinmemberAlexander Werner25-Aug-05 1:47 
GeneralRe: On lost focus - Hotkeys should get unregistered Pinmembersona_zar25-Aug-05 3:42 
GeneralRe: On lost focus - Hotkeys should get unregistered Pinmembersona_zar25-Aug-05 4:25 
GeneralRe: On lost focus - Hotkeys should get unregistered PinmemberSkoobie Du26-Jun-07 1:59 
GeneralRe: On lost focus - Hotkeys should get unregistered Pinmemberekb02116-Jul-07 10:52 
GeneralUpdate to RegisterHotKey method PinsussRick Hobbs @ NeoWorks24-Sep-04 0:47 
GeneralRe: Update to RegisterHotKey method Pinmembertimbits21410-Dec-04 19:29 
GeneralRe: Update to RegisterHotKey method Pinmembertimbits21411-Dec-04 12:13 
GeneralRe: Update to RegisterHotKey method PinmemberXaroth18-May-06 0:22 
GeneralRe: Update to RegisterHotKey method PinmembercountryBumkin15-Jun-06 9:11 
GeneralRe: Update to RegisterHotKey method Pinmemberolveram730-Jun-06 14:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 17 Oct 2002
Article Copyright 2002 by Alexander Werner
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid