I'm writing a program to move the cursor with just the arraw keys. The idea is to press the ctrl button and then the arrow keys to move the cursor. I have alreday done the moving bit and figured out how to get a smooth and humen like action. I just have a problem when it comes to the global hotkeys...
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(String sClassName, String sAppName);
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
I have set the DllImport in the global araea.
IntPtr thisWindow = FindWindow(null, "Form1");
RegisterHotKey(thisWindow, 1, (uint)fsModifiers.Control, (uint)Keys.W);
Later in the Form1_Load I find the window and then later sets a hotkey, in this case it's Control + W (0x0002 + W)
protected override void WndProc(ref Message keyPressed)
{
if (keyPressed.Msg == 0x0312)
{
}
base.WndProc(ref keyPressed);
}
Last I have this method which will detect if the hotkey was pressed, but when I press the hotkey, nothing happens. I have tried to set a brekpoint in (if (keyPressed.Msg == 0x0312)), but the breakpoint dose not go off. Why could this be?