Hey, I would like to call a few functions from a static method, but it seems I can't.
More specifically, I would like to start or stop a timer from a static hook, called when you click your left mouse button.
Here is the code
//When you click...
public static IntPtr HookCallback(
int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode >= 0 &&
MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam)
{
MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
if(bool1 == true){
if(checkBox1.Checked == true){
timer1.Start();
}
}
}
if (nCode >= 0 &&
MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam)
{
MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
if(bool1 == true){
if(checkBox1.Checked == true){
timer1.Stop();
}
}
}
return CallNextHookEx(_hookID, nCode, wParam, lParam);
}
The timer, checkbox and bool are all trying to be called but can't be since the method is static.
Could I change the method to be non-static? Because I've tried that, and it requires an object refrence, and when I put 'object sender' in it, it throws another error etc.
Please tell me if there is a way of doing this!