Example #1
0
        private void HookOnMouseMove(WINAPI.MSLLHOOKSTRUCT mouseStruct)
        {
            if (_downPosition == null || _timer == null)
            {
                return;
            }

            if (_timer.ElapsedMilliseconds > _steadyThresholdMilliseconds)
            {
                Console.WriteLine($"STEADY THRESHOLD");
                Reset();
                return;
            }

            var deltaX   = mouseStruct.pt.x - _downPosition.Value.x;
            var deltaY   = mouseStruct.pt.y - _downPosition.Value.y;
            var distance = Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY));

            if (distance > _steadyDistancePixels)
            {
                Console.WriteLine($"DISTANCE THRESHOLD");
                WINAPI.mouse_event((int)WINAPI.MouseFlags.MOUSEEVENTF_LEFTUP, (uint)_downPosition.Value.x, (uint)_downPosition.Value.y, 0, 0);

                Reset();
                return;
            }

            Console.WriteLine($"MOVED: {distance} px");
        }
Example #2
0
 private void HookOnLeftButtonUp(WINAPI.MSLLHOOKSTRUCT mouseStruct)
 {
     Reset();
     Console.WriteLine("MOUSEUP");
 }
Example #3
0
 private void HookOnLeftButtonDown(WINAPI.MSLLHOOKSTRUCT mouseStruct)
 {
     _timer        = Stopwatch.StartNew();
     _downPosition = mouseStruct.pt;
     Console.WriteLine("MOUSEDOWN");
 }