Please follow the following instructions to create a sample application with smart hotkey handler.

Steps:
1) Create a new Windows Application from Visual Studio 2008.
2) Add Smart Hotkey control to Toolbox (if not available) then drag and drop on to your form.
3) Open your form code file and add following line of code at constructor of the form.

Code:
this.hotKey1.HotKeyPressed += new SmartHotKey.HotKey.HotKeyEventHandler(hotKey1_HotKeyPressed);

4) Add the hotkey press event handler.

Code:
void hotKey1_HotKeyPressed(object sender, SmartHotKey.HotKeyEventArgs e)
{
MessageBox.Show(e.HotKey);
}

5) Register your required hotkeys.

Code:
//normal keys
this.hotKey1.AddHotKey("S");
this.hotKey1.AddHotKey("A");

//normal keys with keymodifiers
this.hotKey1.AddHotKey("ControlShiftAlt+U");
this.hotKey1.AddHotKey("ControlShiftE");

//function keys
this.hotKey1.AddHotKey("F2");
this.hotKey1.AddHotKey("F9");

//function keys with keymodifiers
this.hotKey1.AddHotKey("Shift+F1");
//other keysHome,End,PageDown,PageUp and Delete
this.hotKey1.AddHotKey("Shift+End");
this.hotKey1.AddHotKey("End");
6) Add following line of code inside of the Dispose method.

Code:

//remove all keys
this.hotKey1.RemoveAllKeys();

//remove specific key
this.hotKey1.RemoveKey("Shift+End"); //you can call this method where ever you want to remove a hotkey event handle.

Last edited Feb 19, 2010 at 1:24 PM by eshock, version 2

Comments

No comments yet.