Sending specific keys on the Numpad like +, -, / or Enter (simulating a keypress)

后端 未结 3 1024
离开以前
离开以前 2021-01-12 20:56

I am working on a project where it is necessary to simulate key-presses to cause specific behaviours in a different application.

All is running well and fine, using

3条回答
  •  执念已碎
    2021-01-12 21:44

    I found this here works for me !

    protected override void WndProc(ref Message m)
    {
         if (m.Msg == 256 && m.WParam.ToInt32() == 13)
         {   // WM_KEYDOWN == 256, Enter == 13
             if ((m.LParam.ToInt32() >> 24) == 0)
             {
                 MessageBox.Show("main enter pressed!");
             }
             else
             {
                 MessageBox.Show("numpad enter pressed!");
             }
          }
          else
          {
             base.WndProc(ref m);
          }
    }
    

提交回复
热议问题