/// <summary>Emulates a foreground key press.</summary> /// <param name="hWnd">The handle to the window that will receive the key press.</param> /// <returns>Returns whether the key succeeded to be pressed or not.</returns> public bool PressForeground(IntPtr hWnd) { bool alt = false, ctrl = false, shift = false; switch (ShiftType) { case Messaging.ShiftType.ALT: alt = true; break; case Messaging.ShiftType.CTRL: ctrl = true; break; case Messaging.ShiftType.NONE: if (!Messaging.ForegroundKeyPress(hWnd, this)) { _buttonCounter++; if (_buttonCounter == 2) { _buttonCounter = 0; return(false); } PressForeground(hWnd); } return(true); case Messaging.ShiftType.SHIFT: shift = true; break; } if (!Messaging.ForegroundKeyPressAll(hWnd, this, alt, ctrl, shift)) { _buttonCounter++; if (_buttonCounter == 2) { _buttonCounter = 0; return(false); } PressForeground(hWnd); } return(true); }
public bool PressForeground() { switch (ShiftType) { case Messaging.ShiftType.NONE: if (!Messaging.ForegroundKeyPress(this)) { _buttonCounter++; if (_buttonCounter == 2) { _buttonCounter = 0; return(false); } PressForeground(); } return(true); } return(true); }
/// <summary>Emulates a foreground key press.</summary> /// <param name="hWnd">The handle to the window that will receive the key press.</param> /// <returns>Returns whether the key succeeded to be pressed or not.</returns> public bool PressForeground(IntPtr hWnd) { bool alt = (this.ShiftType & MessagingApi.ShiftType.ALT) != 0; bool ctrl = (this.ShiftType & MessagingApi.ShiftType.CTRL) != 0; bool shift = (this.ShiftType & MessagingApi.ShiftType.SHIFT) != 0; int counter = 0; while (counter < RetryCount) { if (Messaging.ForegroundKeyPress(hWnd, this, alt, ctrl, shift)) { return(true); } counter++; } return(false); }
public bool PressForeground() { if (this.ShiftType != MessagingApi.ShiftType.NONE) { return(false); } int counter = 0; while (counter < RetryCount) { if (Messaging.ForegroundKeyPress(this)) { return(true); } counter++; } return(false); }