/// <summary> /// Implements <see cref="IMouse.Click(MouseButton)"/> /// </summary> public virtual void Click(MouseButton mouseButton) { var currentClickLocation = Location; // Check if the location is the same as with last click if (LastClickLocations[mouseButton].Equals(currentClickLocation)) { // Get the timeout needed to not fire a double click var timeout = DoubleClickTime - DateTime.Now.Subtract(LastClickTimes[mouseButton]).Milliseconds; // Wait the needed time to prevent the double click if (timeout > 0) { Thread.Sleep(timeout + ExtraMillisecondsBecauseOfBugInWindows); } } // Perform the click MouseWin32.MouseButtonUpAndDown(mouseButton); // Update the time and location LastClickTimes[mouseButton] = DateTime.Now; LastClickLocations[mouseButton] = Location; }
/// <summary> /// Implements <see cref="IMouse.DoubleClick(MouseButton)"/> /// </summary> public virtual void DoubleClick(MouseButton mouseButton) { MouseWin32.MouseButtonUpAndDown(mouseButton); Thread.Sleep(CoreAppXmlConfiguration.Instance.DoubleClickInterval); MouseWin32.MouseButtonUpAndDown(mouseButton); }