public bool Down(IntPtr hWnd, bool foreground) { switch (ShiftType) { case Messaging.ShiftType.NONE: if (foreground) { if (!Messaging.ForegroundKeyDown(hWnd, this)) { _buttonCounter++; if (_buttonCounter == 2) { _buttonCounter = 0; return(false); } Down(hWnd, true); } } else { if (!Messaging.SendMessageDown(hWnd, this, true)) { _buttonCounter++; if (_buttonCounter == 2) { _buttonCounter = 0; return(false); } Down(hWnd, false); } } return(true); } return(true); }
public bool Down(IntPtr hWnd, bool foreground = false) { if (this.ShiftType != MessagingApi.ShiftType.NONE) { return(false); } int counter = 0; while (counter < RetryCount) { if (foreground) { if (Messaging.ForegroundKeyDown(hWnd, this)) { return(true); } } else { if (!Messaging.SendMessageKeyDown(hWnd, this, true)) { return(true); } } counter++; } return(false); }