Ejemplo n.º 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");
        }
Ejemplo n.º 2
0
        static bool MsgProc(IntPtr hinstance, IntPtr hPrevInstance, string lpCmdLine, int nCmdShow)
        {
            WINAPI.MSG msg;

            sbyte hasMessage;

            while ((hasMessage = WINAPI.GetMessage(out msg, IntPtr.Zero, 0, 0)) != 0 && hasMessage != -1)
            {
                WINAPI.TranslateMessage(ref msg);
                WINAPI.DispatchMessage(ref msg);
            }

            return(msg.wParam == UIntPtr.Zero);
        }