如下,发送Ctrl+Shift+/,消息如下:
1 [DllImport("user32.dll", EntryPoint = "keybd_event", SetLastError = true)] 2 public static extern void keybd_event( 3 byte bVk, //虚拟键值 4 byte bScan,// 一般为0 5 int dwFlags, //这里是整数类型 0 为按下,2为释放 6 int dwExtraInfo //这里是整数类型 一般情况下设成为 0 7 ); 8 private void ButtonBase_OnClick(object sender, RoutedEventArgs e) 9 { 10 OutputTextBox.Focus(); 11 keybd_event((byte)Keys.LControlKey, 0, 0, 0); 12 keybd_event((byte)Keys.LShiftKey, 0, 0, 0); 13 keybd_event((byte)Keys.Divide, 0, 0, 0); 14 keybd_event((byte)Keys.LControlKey, 0, 2, 0); 15 keybd_event((byte)Keys.LShiftKey, 0, 2, 0); 16 keybd_event((byte)Keys.Divide, 0, 2, 0); 17 }
发送结果:
参考资料:
原文地址:https://www.cnblogs.com/kybs0/p/11360950.html
时间: 2024-10-13 07:35:12