Exemple #1
0
        /// <summary>
        ///     Move to the start
        /// </summary>
        /// <returns>bool if this worked</returns>
        public bool Start()
        {
            var        result = false;
            ScrollInfo scrollInfoBefore;
            var        hasScrollInfo = TryRetrievePosition(out scrollInfoBefore);

            switch (ScrollMode)
            {
            case ScrollModes.KeyboardPageUpDown:
                InputGenerator.KeyDown(VirtualKeyCodes.CONTROL);
                InputGenerator.KeyPress(VirtualKeyCodes.HOME);
                InputGenerator.KeyUp(VirtualKeyCodes.CONTROL);
                result = true;
                break;

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

            case ScrollModes.AbsoluteWindowMessage:
                result = hasScrollInfo;
                if (hasScrollInfo)
                {
                    // Calculate start position, clone the scrollInfoBefore
                    var scrollInfoForStart = scrollInfoBefore;
                    scrollInfoForStart.Position = scrollInfoBefore.Minimum;
                    result = ApplyPosition(ref scrollInfoForStart);
                }
                break;

            case ScrollModes.MouseWheel:
                result = true;
                while (!IsAtStart)
                {
                    if (!Previous())
                    {
                        break;
                    }
                }
                break;
            }
            return(result);
        }
Exemple #2
0
        public void SendInput()
        {
            switch (Type)
            {
            case KeyType.KeyDown:
                InputGenerator.KeyDown((VirtualKeyCodes)(Num + 48));
                Debug.WriteLine("Pushed" + Num.ToString());
                break;

            case KeyType.KeyUp:
                InputGenerator.KeyUp((VirtualKeyCodes)(Num + 48));
                Debug.WriteLine("Released " + Num.ToString());
                break;

            case KeyType.KeyPress:
                InputGenerator.KeyPress((VirtualKeyCodes)(Num + 48));
                Debug.WriteLine("Pressed" + Num.ToString());
                break;
            }
        }