コード例 #1
0
        /// <summary>
        /// Dispatches a `mousemove` event.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="options"></param>
        /// <returns>Task</returns>
        public async Task MoveAsync(decimal x, decimal y, MoveOptions options = null)
        {
            options = options ?? new MoveOptions();

            decimal fromX = _x;
            decimal fromY = _y;

            _x = x;
            _y = y;
            int steps = options.Steps;

            for (var i = 1; i <= steps; i++)
            {
                await _client.SendAsync("Input.dispatchMouseEvent", new Dictionary <string, object>(){
                    { "type", "mouseMoved" },
                    { "button", _button },
                    { "x", fromX + (_x - fromX) * ((decimal)i / steps) },
                    { "y", fromY + (_y - fromY) * ((decimal)i / steps) },
                    { "modifiers", _keyboard.Modifiers }
                });
            }
        }
コード例 #2
0
ファイル: Mouse.cs プロジェクト: mauriciogracia/PuppeteerDemo
        /// <summary>
        /// Dispatches a <c>mousemove</c> event.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="options"></param>
        /// <returns>Task</returns>
        public async Task MoveAsync(decimal x, decimal y, MoveOptions options = null)
        {
            options = options ?? new MoveOptions();

            decimal fromX = _x;
            decimal fromY = _y;

            _x = x;
            _y = y;
            int steps = options.Steps;

            for (var i = 1; i <= steps; i++)
            {
                await _client.SendAsync("Input.dispatchMouseEvent", new InputDispatchMouseEventRequest
                {
                    Type      = MouseEventType.MouseMoved,
                    Button    = _button,
                    X         = fromX + ((_x - fromX) * ((decimal)i / steps)),
                    Y         = fromY + ((_y - fromY) * ((decimal)i / steps)),
                    Modifiers = _keyboard.Modifiers
                }).ConfigureAwait(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// Dispatches a <c>mousemove</c> event.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="options"></param>
        /// <returns>Task</returns>
        public async Task MoveAsync(decimal x, decimal y, MoveOptions options = null)
        {
            options = options ?? new MoveOptions();

            decimal fromX = _x;
            decimal fromY = _y;

            _x = x;
            _y = y;
            int steps = options.Steps;

            for (var i = 1; i <= steps; i++)
            {
                await _client.SendAsync("Input.dispatchMouseEvent", new Dictionary <string, object>
                {
                    { MessageKeys.Type, "mouseMoved" },
                    { MessageKeys.Button, _button },
                    { MessageKeys.X, fromX + ((_x - fromX) * ((decimal)i / steps)) },
                    { MessageKeys.Y, fromY + ((_y - fromY) * ((decimal)i / steps)) },
                    { MessageKeys.Modifiers, _keyboard.Modifiers }
                }).ConfigureAwait(false);
            }
        }