Listening To Hotkeys
Including hotkey-listening logic at runtime
// Add a HotkeyPressed event.
hkl.HotkeyPressed += Hkl_HotkeyPressed;
private void Hkl_HotkeyPressed(object sender, HotkeyEventArgs e)
{
if (e.Hotkey == hotkey1)
MessageBox.Show($"First hotkey '{hotkey1}' was pressed.");
if (e.Hotkey == hotkey2)
MessageBox.Show($"Second hotkey '{hotkey2}'was pressed.");
}private void Hkl_HotkeyPressed(object sender, HotkeyEventArgs e)
{
if (e.Hotkey == hotkey1)
{
MessageBox.Show(
"Application:" + e.SourceApplication.Name + "\n" +
"Title: " + e.SourceApplication.Title + "\n" +
"ID: " + e.SourceApplication.ID + "\n" +
"Handle: " + e.SourceApplication.Handle + "\n" +
"Path: " + e.SourceApplication.Path + "\n"
);
}
}Last updated