コード例 #1
0
        /// <summary>
        ///     Go to the previous "page"
        /// </summary>
        /// <returns>bool if this worked</returns>
        public bool Previous()
        {
            var result        = false;
            var hasScrollInfo = TryRetrievePosition(out var scrollInfoBefore);

            switch (ScrollMode)
            {
            case ScrollModes.KeyboardPageUpDown:
                result = KeyboardInputGenerator.KeyPresses(VirtualKeyCode.Prior) == 2;
                break;

            case ScrollModes.WindowsMessage:
                result = SendScrollMessage(ScrollBarCommands.SB_PAGEUP);
                break;

            case ScrollModes.AbsoluteWindowMessage:
                if (!hasScrollInfo)
                {
                    return(false);
                }
                // Calculate previous position, clone the scrollInfoBefore
                var scrollInfoForPrevious = scrollInfoBefore;
                scrollInfoForPrevious.Position = Math.Max(scrollInfoBefore.Minimum, scrollInfoBefore.Position - (int)scrollInfoBefore.PageSize);
                result = ApplyPosition(ref scrollInfoForPrevious);
                break;

            case ScrollModes.MouseWheel:
                var bounds      = ScrollingWindow.GetInfo().Bounds;
                var middlePoint = new NativePoint(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
                result = MouseInputGenerator.MoveMouseWheel(WheelDelta, middlePoint) == 1;
                break;
            }
            return(result);
        }
コード例 #2
0
 private void TestMouseInput()
 {
     MouseInputGenerator.MoveMouse(new NativePoint(10, 10));
     Thread.Sleep(100);
     MouseInputGenerator.MoveMouse(new NativePoint(100, 100));
     Thread.Sleep(100);
 }