public EventSourceEventArgs <MouseEvent> GetEventArgs(EventSourceEventArgs <MouseInput> e)
        {
            var Wait = LastInput != default && e.Timestamp - LastInput.Timestamp is var Duration && Duration > TimeSpan.Zero
                ? new Wait(Duration)
                : null
            ;

            var Move = (LastInput?.Data.X != e.Data.X || LastInput?.Data.Y != e.Data.Y)
                ? new MouseMoveAbsolute(e.Data.X, e.Data.Y)
                : null
            ;

            CurrentPosition = Move ?? CurrentPosition;


            var Scroll = e.Data.ButtonStatus == ButtonStatus.Scrolled
                ? new ButtonScroll(e.Data.Button, e.Data.ScrollOffset)
                : null
            ;

            var Down = e.Data.ButtonStatus == ButtonStatus.Pressed
                ? new ButtonDown(e.Data.Button)
                : null
            ;

            if (Down is { })
 private void Monitor_KeyEvent(object sender, EventSourceEventArgs <KeyboardEvent> e)
 {
     if (State.Next(e.Data) == StateMachineResult.Complete)
     {
         var args = new KeySequenceEventArgs()
         {
             Input    = e,
             Sequence = Sequence
         };
         Triggered?.Invoke(this, args);
     }
 }
Пример #3
0
        protected EventSourceEventArgs InvokeMany(params Func <EventSourceEventArgs, EventSourceEventArgs>[] Actions)
        {
            var ret = new EventSourceEventArgs(DateTimeOffset.UtcNow);;

            foreach (var item in Actions)
            {
                if (ret.Next_Event_Enabled)
                {
                    var tret = item(ret);
                    ret.Next_Event_Enabled = tret.Next_Event_Enabled;
                    ret.Next_Hook_Enabled  = tret.Next_Hook_Enabled;
                }
            }

            return(ret);
        }
        protected EventSourceEventArgs<KeyInput> GetInputEventArgs(GlobalKeyboardMessage Message, GlobalKeyboardEventSourceCallbackData keyboardHookStruct) {

            var keyData = keyboardHookStruct.Data.KeyCode;

            var isKeyDown = Message.IsKeyDown();
            var isKeyUp = Message.IsKeyUp();

            var isExtendedKey = keyboardHookStruct.Data.Flags.HasFlag(KeyboardHookStructFlags.Extended);

            var Status = KeyStatusValue.Compute(isKeyDown, isKeyUp);

            var Data = new KeyInput(keyData, isExtendedKey, keyboardHookStruct.Data.ScanCode, Status);
            var ret = EventSourceEventArgs.Create(keyboardHookStruct.Data.Time, Data, keyboardHookStruct);

            return ret;
        }
Пример #5
0
        protected EventSourceEventArgs InvokeEvent <T>(EventSourceEventArgs args, EventHandler <EventSourceEventArgs <T> > Event, T Data, object RawData, DateTimeOffset Timestamp)
        {
            var ret = new EventSourceEventArgs(Timestamp);

            ret.Next_Event_Enabled = args.Next_Event_Enabled;
            ret.Next_Hook_Enabled  = args.Next_Hook_Enabled;

            if (!EqualityComparer <T> .Default.Equals(Data, default))
            {
                var Args = new EventSourceEventArgs <T>(Timestamp, Data, RawData)
                {
                    Next_Event_Enabled = args.Next_Event_Enabled,
                    Next_Hook_Enabled  = args.Next_Hook_Enabled,
                };

                Event?.Invoke(this, Args);

                ret.Next_Event_Enabled = Args.Next_Event_Enabled;
                ret.Next_Hook_Enabled  = Args.Next_Hook_Enabled;
            }

            return(ret);
        }
Пример #6
0
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, IReadOnlyList <DragDrop>?Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, DragFinished, Data, RawData, Timestamp);
Пример #7
0
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, ButtonScroll?Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, ButtonScroll, Data, RawData, Timestamp);
Пример #8
0
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, MouseMove?Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, MouseMove, Data, RawData, Timestamp);
Пример #9
0
        protected override bool Callback(CallbackData data)
        {
            var Timestamp = DateTimeOffset.UtcNow;

            var NewData = data.ToCurrentThreadMouseEventSourceCallbackData();

            var Button   = default(ButtonCode);
            var Location = default(POINT);
            var Scroll   = default(int);
            var Status   = default(ButtonStatus);

            Location.X = NewData.Data.Point.X;
            Location.Y = NewData.Data.Point.Y;

            switch (NewData.Message)
            {
            case WindowMessage.WM_MOUSEMOVE:
            case WindowMessage.WM_MOUSEMOVE_NC:
                break;

            case WindowMessage.WM_LBUTTONDOWN:
            case WindowMessage.WM_LBUTTONDOWN_NC:
                Button = ButtonCode.Left;
                Status = ButtonStatus.Pressed;
                break;

            case WindowMessage.WM_RBUTTONDOWN:
            case WindowMessage.WM_RBUTTONDOWN_NC:
                Button = ButtonCode.Right;
                Status = ButtonStatus.Pressed;
                break;

            case WindowMessage.WM_MBUTTONDOWN:
            case WindowMessage.WM_MBUTTONDOWN_NC:
                Button = ButtonCode.Middle;
                Status = ButtonStatus.Pressed;
                break;

            case WindowMessage.WM_LBUTTONUP:
            case WindowMessage.WM_LBUTTONUP_NC:
                Button = ButtonCode.Left;
                Status = ButtonStatus.Released;
                break;

            case WindowMessage.WM_RBUTTONUP:
            case WindowMessage.WM_RBUTTONUP_NC:
                Button = ButtonCode.Right;
                Status = ButtonStatus.Released;
                break;

            case WindowMessage.WM_MBUTTONUP:
            case WindowMessage.WM_MBUTTONUP_NC:
                Button = ButtonCode.Middle;
                Status = ButtonStatus.Released;
                break;

            case WindowMessage.WM_LBUTTONDBLCLK:
            case WindowMessage.WM_LBUTTONDBLCLK_NC:
                Button = ButtonCode.Left;
                Status = ButtonStatus.Pressed;
                break;

            case WindowMessage.WM_RBUTTONDBLCLK:
            case WindowMessage.WM_RBUTTONDBLCLK_NC:
                Button = ButtonCode.Right;
                Status = ButtonStatus.Pressed;
                break;

            case WindowMessage.WM_MBUTTONDBLCLK:
            case WindowMessage.WM_MBUTTONDBLCLK_NC:
                Button = ButtonCode.Middle;
                Status = ButtonStatus.Pressed;
                break;

            case WindowMessage.WM_MOUSEWHEEL_H:
                Button = ButtonCode.HScroll;
                Status = ButtonStatus.Scrolled;
                Scroll = NewData.Data.MouseData.HiWord;
                break;

            case WindowMessage.WM_MOUSEWHEEL_V:
                Button = ButtonCode.VScroll;
                Status = ButtonStatus.Scrolled;
                Scroll = NewData.Data.MouseData.HiWord;
                break;

            case WindowMessage.WM_XBUTTONDOWN:
            case WindowMessage.WM_XBUTTONDOWN_NC:
                Button = XButton(NewData.Data);
                Status = ButtonStatus.Pressed;
                break;

            case WindowMessage.WM_XBUTTONUP:
            case WindowMessage.WM_XBUTTONUP_NC:
                Button = XButton(NewData.Data);
                Status = ButtonStatus.Released;
                break;

            case WindowMessage.WM_XBUTTONDBLCLK:
            case WindowMessage.WM_XBUTTONDBLCLK_NC:
                Button = XButton(NewData.Data);
                Status = ButtonStatus.Pressed;
                break;

            default:
                break;
            }

            var e      = new EventSourceEventArgs <MouseInput>(Timestamp, new MouseInput(Button, Location, Scroll, Status), NewData);
            var Events = State.GetEventArgs(e);
            var ret    = InvokeMany(Events.Data, NewData, Events.Timestamp);

            return(ret.Next_Hook_Enabled);
        }
Пример #10
0
 public EventSourceEventArgs <MouseEvent> GetEventArgs(EventSourceEventArgs <MouseInput> e)
 {
     var Wait = LastInput is { } && e.Timestamp - LastInput.Timestamp is var Duration && Duration > TimeSpan.Zero
Пример #11
0
 public KeyChordEventArgs(EventSourceEventArgs <KeyboardEvent> Input, ChordClick Chord)
 {
     this.Input = Input;
     this.Chord = Chord;
 }
Пример #12
0
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, IReadOnlyCollection <DragStart> Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, DragStarted, Data, RawData, Timestamp);
Пример #13
0
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, Wait Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, Wait, Data, RawData, Timestamp);
Пример #14
0
 public TextSequenceEventArgs(EventSourceEventArgs <KeyboardEvent> Input, TextClick Sequence)
 {
     this.Input    = Input;
     this.Sequence = Sequence;
 }
Пример #15
0
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, TextClick Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, TextClick, Data, RawData, Timestamp);
Пример #16
0
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, ButtonDoubleClick?Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, ButtonDoubleClick, Data, RawData, Timestamp);
Пример #17
0
 private void Monitor_KeyEvent(object?sender, EventSourceEventArgs <KeyboardEvent> e)
 {
     if (State is { } && State.TryNext(e.Data, out var Status) && Status == StateMachineResult.Complete)
 protected EventSourceEventArgs InvokeEvent(EventSourceEventArgs args, KeyboardEvent?Data, object RawData, DateTimeOffset Timestamp) => InvokeEvent(args, KeyEvent, Data, RawData, Timestamp);