1
votes

I am able to hook(Global Keyboard hook) ALT key in a winform(c#) application. The code is given below.

if ((ModifierKeys == Keys.Alt) && Keys.P == (Keys) vkCode)
{
     SendKeys.Send("Test");
     //MessageBox.Show("test");
     return (IntPtr) 1;
}

If I comment out SendKeys line and uncomment MessageBox line then I can see the messagebox if Alt+P is pressed. But SendKeys.Send doesn't work. Why? But if instead of Alt key if I hook Control or Shift key then there is no problem with SendKeys Command.

1
Try SendKeys.Send("Pest") to see this go wrong in a spectacular way.Hans Passant

1 Answers

1
votes

SendKeys.Send send key press. Actually it does work. But when it send pressed keys Alt+T Alt+E Alt+S Alt+T cause you pressing Alt. That's why you see no results