// Through this method, the keys generated by the Virtual Keyboard are sent to the target control. // In this version, the current target control is always the control with input focus and the keyboard // is only visible when the control (to which the keyboard was previously attached) has input focus. // Therefore, SendKeys.Send offers all the logic needed for this version of the keyboard. // // For future versions, we might consider using the Win32 API SendInput function for greater flexibility. private void SendKeysToTarget(string info) { KeyboardKeyCancelEventArgs cancelArgs = new KeyboardKeyCancelEventArgs(info); OnSendingKey(cancelArgs); if (cancelArgs.Cancel) return; SendKeys.Send(info); OnKeySent(new KeyboardKeyEventArgs(info)); }
/// <summary> /// Raises SendingKey event. /// </summary> /// <param name="e">Provides event arguments.</param> protected virtual void OnSendingKey(KeyboardKeyCancelEventArgs e) { KeyCancelEventHandler handler = SendingKey; if (handler != null) handler(this, e); }
private void VirtualKeyboardSendingKey(object sender, KeyboardKeyCancelEventArgs e) { OnSendingKey(e); }