OK, I'm not agreeing with how you are going about this, but what you are trying is not working because you are trying to detect key presses in a different application than yours. If you want to determine what keys are down, you can use this class:
static class NativeMethods
{
private const int KEY_PRESSED = 0x8000;
private const int VK_CONTROL = 0x11;
private const int VK_RETURN = 0x0D;
[DllImport("user32.dll")]
static extern short GetKeyState(int key);
public static bool IsControlEnterKeyDown()
{
return (GetKeyState(VK_CONTROL) & KEY_PRESSED) != 0 &&
(GetKeyState(VK_RETURN) & KEY_PRESSED) != 0;
}
}
In your timer code you call it like this:
if (NativeMethods.IsControlEnterKeyDown())
{
}
However, please keep in mind that its unlikely that your keys will be down when your timer ticks, most good typists type at 60-80 words per minute, a word being 5 characters, which means that they hit keys at the rate of 5-6 PER SECOND. The keys are only down for a fraction of a second, probably around 10ms, which is much less than the resolution of the Timer can hit.
This means that your key presses will be unreliable, and the user will have to hold the keys down until your timer hits.