Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using HotKey;
- public partial class MainForm : Form
- {
- private Hotkeys.GlobalHotkey ghk;
- public MainForm()
- {
- InitializeComponent();
- ghk = new Hotkeys.GlobalHotkey(Constants.ALT + Constants.SHIFT, Keys.M, this);
- }
- private void HandleHotkey()
- {
- WriteLine("Hotkey pressed!");
- }
- protected override void WndProc(ref Message m)
- {
- base.WndProc(ref m);
- switch (m.Msg)
- {
- case Constants.WM_HOTKEY_MSG_ID:
- // Hotkey was pressed
- HandleHotkey();
- break;
- }
- }
- private void MainForm_Load(object sender, EventArgs e)
- {
- WriteLine("Trying to register SHIFT+ALT+O");
- if (ghk.Register())
- {
- this.WindowState = FormWindowState.Minimized;
- this.ShowInTaskbar = false;
- WriteLine("Hotkey registered.");
- }
- else
- {
- WriteLine("Hotkey failed to register");
- }
- }
- private void WriteLine(string text)
- {
- textBox1.Text += text + Environment.NewLine;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement