Example #1
0
 private static void ClickCentered(BasicElement element, MouseButtons buttons, ModifierKeys modifierKeys)
 {
     Cursor.Position = GetCenterPoint(element).ToDrawingPoint();
     KeyboardEx.PressKey(modifierKeys);
     WinApi.MouseEvent((int)buttons);
     KeyboardEx.ReleaseKey(modifierKeys);
 }
Example #2
0
 private static void ClickRelative(BasicElement element, MouseButtons button, ModifierKeys modifierKeys, At relativePosition)
 {
     Cursor.Position = relativePosition.GetPoint(element).ToDrawingPoint();
     KeyboardEx.PressKey(modifierKeys);
     WinApi.MouseEvent((int)button);
     KeyboardEx.ReleaseKey(modifierKeys);
 }
Example #3
0
 /// <summary>
 /// Executes a mouse left click while holding specific modifier keys.
 /// </summary>
 /// <param name="modifierKeys">The modifier keys to be hold while the click is executed.</param>
 /// <returns>A combinable Do to be able to append additional actions.</returns>
 public static CombinableDo Click(ModifierKeys modifierKeys)
 {
     return(WrapIt(() =>
     {
         LogPool.Append("Click with the left mouse button and with the modifier keys '{0}' pressed.", modifierKeys);
         KeyboardEx.PressKey(modifierKeys);
         WinApi.MouseEvent((int)MouseButtons.Left);
         KeyboardEx.ReleaseKey(modifierKeys);
     },
                   string.Format("Cannot click the left mouse button with the modifier keys '{0}' pressed.", modifierKeys)));
 }
Example #4
0
        /// <summary>
        /// Executes a mouse click at a specific position within the screen by using specific mouse buttons and holding a modifier key.
        /// </summary>
        /// <param name="buttons">The mouse buttons which will be clicked.</param>
        /// <param name="modifierKeys">The modifier keys to be hold while the click is executed.</param>
        /// <param name="screenCoordinate">The point on the whole screen where to click.</param>
        /// <returns>A combinable Do to be able to append additional actions.</returns>
        public static CombinableDo Click(MouseButtons buttons, ModifierKeys modifierKeys, Point screenCoordinate)
        {
            return(WrapIt(() =>
            {
                LogPool.Append("Click with the modifier keys '{0}' on the screen coordinate '{1}'.", modifierKeys, screenCoordinate);

                Cursor.Position = screenCoordinate.ToDrawingPoint();
                KeyboardEx.PressKey(modifierKeys);
                WinApi.MouseEvent((int)buttons);
                KeyboardEx.ReleaseKey(modifierKeys);
            },
                          string.Format("Cannot click with the modifier keys '{0}' on the screen coordinate '{1}'.", modifierKeys, screenCoordinate)));
        }