I dont understand how these code works here :
m_MouseHookManager.MouseDoubleClick+=HookManager_MouseDoubleClick;
m_MouseHookManager.MouseDoubleClick -= HookManager_MouseDoubleClick;
m_KeyboardHookManager.KeyPress +=HookManager_KeyPress;
m_KeyboardHookManager.KeyPress -=HookManager_KeyPress;
My full Code is here :
using System;
using System.Windows.Forms;
using MouseKeyboardActivityMonitor.WinApi;
namespace MouseKeyboardActivityMonitor.Demo
{
public partial class TestFormHookListeners : Form
{
private readonly KeyboardHookListener m_KeyboardHookManager;
private readonly MouseHookListener m_MouseHookManager;
public TestFormHookListeners()
{
InitializeComponent();
m_KeyboardHookManager = new KeyboardHookListener(new GlobalHooker());
// Hooks are not active after instantiation. You need to use either Enabled property or call Start()()()() method
m_KeyboardHookManager.Enabled = true;//True - The Hook is presently installed, activated, and will fire events.
m_MouseHookManager = new MouseHookListener(new GlobalHooker());
m_MouseHookManager.Enabled = true;
}
#region Check boxes to set or remove particular event handlers.
private void checkBoxMouseDoubleClick_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxMouseDoubleClick.Checked)
{
m_MouseHookManager.MouseDoubleClick += HookManager_MouseDoubleClick;
}
else
{
m_MouseHookManager.MouseDoubleClick -= HookManager_MouseDoubleClick;
}
}
private void checkBoxKeyPress_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxKeyPress.Checked)
{
m_KeyboardHookManager.KeyPress +=HookManager_KeyPress;
}
else
{
m_KeyboardHookManager.KeyPress -=HookManager_KeyPress;
}
}
#endregion
#region Event handlers of particular events. They will be activated when an appropriate checkbox is checked.
private void HookManager_KeyPress(object sender, KeyPressEventArgs e)
{
Log(string.Format("KeyPress \t\t {0}\n", e.KeyChar));
}
private void HookManager_MouseDoubleClick(object sender, MouseEventArgs e)
{
Log(string.Format("MouseDoubleClick \t\t {0}\n", e.Button));
}
private void Log(string text)
{
textBoxLog.AppendText(text);
textBoxLog.ScrollToCaret();
}
#endregion
private void checkBoxEnabled_CheckedChanged(object sender, EventArgs e)
{
m_MouseHookManager.Enabled = checkBoxEnabled.Checked;
m_KeyboardHookManager.Enabled = checkBoxEnabled.Checked;
}
private void radioHooksType_CheckedChanged(object sender, EventArgs e)
{
Hooker hook;
if (radioApplication.Checked)
{
hook = new AppHooker();//Provides methods for subscription and unsubscription to application mouse and keyboard hooks.
}
else
{
hook = new GlobalHooker();//Provides methods for subscription and unsubscription to global mouse and keyboard hooks.
}
m_KeyboardHookManager.Replace(hook);
m_MouseHookManager.Replace(hook);//hook->An AppHooker or GlobalHooker object.
//Enables you to switch from application hooks to global hooks
//and vice versa on the fly without unsubscribing from events.
//Component remains enabled or disabled state after this call as it was before.
//Declaration Syntax
}
private void HookManager_Supress(object sender, MouseEventExtArgs e)
{
if (e.Button != MouseButtons.Right) { return; }
Log("Suppressed.\n");
e.Handled = true;
}
}
}
Can anybody help to understand that???
I want by this that whenever a F5 key-pressed my application will be active and then it checks if double-click happen it gives a message ....
**How can i modify that.....??????**