Пример #1
0
        private void lockAim(float x, float y)
        {
            const int flagMove     = (int)UnmanagedUtil.MouseEvent.MOUSEEVENTF_MOVE;
            const int flagAbsolute = (int)UnmanagedUtil.MouseEvent.MOUSEEVENTF_ABSOLUTE;
            var       screenX      = (int)(x / Screen.width * 65535f);
            var       screenY      = (int)(y / Screen.height * 65535f);

            UnmanagedUtil.mouse_event(flagMove | flagAbsolute, screenX, screenY, 0, 0);
        }
Пример #2
0
        public void onUpdate()
        {
            if (_inputs.Count == 0)
            {
                return;
            }
            var next = _inputs.First();

            if (next.modifierKey != KeyCode.None && next.state == ModifierState.NotApplied)
            {
                UnmanagedUtil.keyDown(VirtualKeys.mappedKeys[next.modifierKey]);
                next.state = ModifierState.Applied;
                return;
            }

            if (next.state == ModifierState.Applied)
            {
                if (Input.GetKeyDown(next.modifierKey))
                {
                    next.state = ModifierState.UseCode;
                }
                return;
            }

            switch (next.type)
            {
            case ManagedInputType.Keyboard:
                UnmanagedUtil.keyPressed(next.code);
                break;

            case ManagedInputType.MouseClick:
                UnmanagedUtil.mouseClick(next.code);
                break;

            case ManagedInputType.MouseWheel:
                UnmanagedUtil.mouseWheelDown();
                break;
            }

            if (next.state == ModifierState.UseCode)
            {
                if (Input.GetKeyUp(next.key) || Input.GetAxis("Mouse ScrollWheel") < 0f || Input.GetMouseButtonUp(next.code))
                {
                    next.state = ModifierState.StopApply;
                }
                return;
            }

            if (next.state == ModifierState.StopApply)
            {
                UnmanagedUtil.keyUp(VirtualKeys.mappedKeys[next.modifierKey]);
            }
            _inputs.Dequeue();
        }