Exemple #1
0
        /// <summary>
        ///     Makes the lParam for a key depending on several settings.
        /// </summary>
        /// <param name="key">
        ///     [16-23 bits] The virtual key.
        /// </param>
        /// <param name="keyUp">
        ///     [31 bit] The transition state.
        ///     The value is always 0 for a <see cref="WindowsMessages.KeyDown" /> message.
        ///     The value is always 1 for a <see cref="WindowsMessages.KeyUp" /> message.
        /// </param>
        /// <param name="fRepeat">
        ///     [30 bit] The previous key state.
        ///     The value is 1 if the key is down before the message is sent, or it is zero if the key is up.
        ///     The value is always 1 for a <see cref="WindowsMessages.KeyUp" /> message.
        /// </param>
        /// <param name="cRepeat">
        ///     [0-15 bits] The repeat count for the current message.
        ///     The value is the number of times the keystroke is autorepeated as a result of the user holding down the key.
        ///     If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
        ///     The repeat count is always 1 for a <see cref="WindowsMessages.KeyUp" /> message.
        /// </param>
        /// <param name="altDown">
        ///     [29 bit] The context code.
        ///     The value is always 0 for a <see cref="WindowsMessages.KeyDown" /> message.
        ///     The value is always 0 for a <see cref="WindowsMessages.KeyUp" /> message.
        /// </param>
        /// <param name="fExtended">
        ///     [24 bit] Indicates whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on
        ///     an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
        /// </param>
        /// <returns>The return value is the lParam when posting or sending a message regarding key press.</returns>
        /// <remarks>
        ///     KeyDown resources: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646280%28v=vs.85%29.aspx
        ///     KeyUp resources:  http://msdn.microsoft.com/en-us/library/windows/desktop/ms646281%28v=vs.85%29.aspx
        /// </remarks>
        private static IntPtr MakeKeyParameter(Keys key, bool keyUp, bool fRepeat, int cRepeat, bool altDown,
                                               bool fExtended)
        {
            // Create the result and assign it with the repeat count
            var result = (uint)cRepeat;

            // Add the scan code with a left shift operation
            result |= (uint)AWindowHelper.MapVirtualKey(key, TranslationTypes.VirtualKeyToScanCode) << 16;
            // Does we need to set the extended flag ?
            if (fExtended)
            {
                result |= 0x1000000;
            }
            // Does we need to set the alt flag ?
            if (altDown)
            {
                result |= 0x20000000;
            }
            // Does we need to set the repeat flag ?
            if (fRepeat)
            {
                result |= 0x40000000;
            }

            // Does we need to set the keyUp flag ?
            if (keyUp)
            {
                result |= 0x80000000;
            }

            return(new IntPtr(result));
        }
Exemple #2
0
        /// <summary>
        ///     Presses the middle button of the mouse at the current cursor position.
        /// </summary>
        public void PressMiddle()
        {
            var input = CreateInput();

            input.Mouse.Flags = MouseFlags.MiddleDown;
            AWindowHelper.SendInput(input);
        }
Exemple #3
0
        /// <summary>
        ///     Presses the right button of the mouse at the current cursor position.
        /// </summary>
        public void PressRight()
        {
            var input = CreateInput();

            input.Mouse.Flags = MouseFlags.RightDown;
            AWindowHelper.SendInput(input);
        }
Exemple #4
0
        /// <summary>
        ///     Releases the middle button of the mouse at the current cursor position.
        /// </summary>
        public void ReleaseMiddle()
        {
            var input = CreateInput();

            input.Mouse.Flags = MouseFlags.MiddleUp;
            AWindowHelper.SendInput(input);
        }
Exemple #5
0
        /// <summary>
        ///     Releases the right button of the mouse at the current cursor position.
        /// </summary>
        public void ReleaseRight()
        {
            var input = CreateInput();

            input.Mouse.Flags = MouseFlags.RightUp;
            AWindowHelper.SendInput(input);
        }
Exemple #6
0
        /// <summary>
        ///     Scrolls vertically using the wheel of the mouse at the current cursor position.
        /// </summary>
        /// <param name="delta">The amount of wheel movement.</param>
        public void ScrollVertically(int delta = 120)
        {
            var input = CreateInput();

            input.Mouse.Flags     = MouseFlags.Wheel;
            input.Mouse.MouseData = delta;
            AWindowHelper.SendInput(input);
        }
Exemple #7
0
        /// <summary>
        ///     Moves the cursor at the specified coordinate.
        /// </summary>
        /// <param name="x">The x-coordinate.</param>
        /// <param name="y">The y-coordinate.</param>
        protected void MoveToAbsolute(int x, int y)
        {
            var input = CreateInput();

            input.Mouse.DeltaX    = CalculateAbsoluteCoordinateX(x);
            input.Mouse.DeltaY    = CalculateAbsoluteCoordinateY(y);
            input.Mouse.Flags     = MouseFlags.Move | MouseFlags.Absolute;
            input.Mouse.MouseData = 0;
            AWindowHelper.SendInput(input);
        }
Exemple #8
0
 /// <summary>
 ///     Gets all the windows that have the specified class name.
 /// </summary>
 /// <param name="className">The class name string.</param>
 /// <returns>A collection of <see cref="ARemoteWindow" />.</returns>
 public IEnumerable <IAWindow> GetWindowsByClassName(string className)
 {
     return(WindowHandles
            .Where(handle => AWindowHelper.GetClassName(handle) == className)
            .Select(handle => new ARemoteWindow(_process, handle)));
 }
Exemple #9
0
 /// <summary>
 ///     Gets all the windows that contain the specified title.
 /// </summary>
 /// <param name="windowTitle">A part a window title string.</param>
 /// <returns>A collection of <see cref="ARemoteWindow" />.</returns>
 public IEnumerable <IAWindow> GetWindowsByTitleContains(string windowTitle)
 {
     return(WindowHandles
            .Where(handle => AWindowHelper.GetWindowText(handle).Contains(windowTitle))
            .Select(handle => new ARemoteWindow(_process, handle)));
 }
Exemple #10
0
 /// <summary>
 ///     Sends the specified message to a window or windows.
 ///     The SendMessage function calls the window procedure for the specified window and does not return until the window
 ///     procedure has processed the message.
 /// </summary>
 /// <param name="message">The message to be sent.</param>
 /// <param name="wParam">Additional message-specific information.</param>
 /// <param name="lParam">Additional message-specific information.</param>
 /// <returns>The return value specifies the result of the message processing; it depends on the message sent.</returns>
 public IntPtr SendMessage(int message, IntPtr wParam, IntPtr lParam)
 {
     return(AWindowHelper.SendMessage(Handle, message, wParam, lParam));
 }
Exemple #11
0
 /// <summary>
 ///     Places (posts) a message in the message queue associated with the thread that created the window and returns
 ///     without waiting for the thread to process the message.
 /// </summary>
 /// <param name="message">The message to be posted.</param>
 /// <param name="wParam">Additional message-specific information.</param>
 /// <param name="lParam">Additional message-specific information.</param>
 public void PostMessage(int message, IntPtr wParam, IntPtr lParam)
 {
     AWindowHelper.PostMessage(Handle, message, wParam, lParam);
 }
Exemple #12
0
 /// <summary>
 ///     Flashes the window. It does not change the active state of the window.
 /// </summary>
 /// <param name="count">The number of times to flash the window.</param>
 /// <param name="timeout">The rate at which the window is to be flashed.</param>
 /// <param name="flags">The flash status.</param>
 public void Flash(int count, TimeSpan timeout, FlashWindowFlags flags = FlashWindowFlags.All)
 {
     AWindowHelper.FlashWindowEx(Handle, flags, count, timeout);
 }
Exemple #13
0
 /// <summary>
 ///     Flashes the window one time. It does not change the active state of the window.
 /// </summary>
 public void Flash()
 {
     AWindowHelper.FlashWindow(Handle);
 }
Exemple #14
0
 /// <summary>
 ///     Activates the window.
 /// </summary>
 public void Activate()
 {
     AWindowHelper.SetForegroundWindow(Handle);
 }