Exemplo n.º 1
0
        void _Thread()
        {
            _tid = Api.GetCurrentThreadId();

            WindowsHook hookK = null, hookM = null;

            if (_usedEvents.Has(UsedEvents.Keyboard))
            {
                hookK = WindowsHook.Keyboard(_KeyboardHookProc);                 //note: if lambda, very slow JIT on first hook event
            }
            if (_usedEvents.Has(UsedEvents.Mouse))
            {
                hookM = WindowsHook.MouseRaw_(_MouseHookProc);
            }
            if (_usedEvents.Has(UsedEvents.MouseEdgeMove))
            {
                _emDetector = new MouseTriggers.EdgeMoveDetector_();
            }
            //tested: don't need JIT-compiling.

            nint idTimer = (hookK != null || hookM != null) ? Api.SetTimer(default, 0, 10_000, null) : 0;
Exemplo n.º 2
0
        void _Thread()
        {
            _tid = AThread.NativeId;

            AHookWin hookK = null, hookM = null;

            if (_usedEvents.Has(UsedEvents.Keyboard))
            {
                hookK = AHookWin.Keyboard(_KeyboardHookProc);                 //note: don't use lambda, because then very slow JIT on first hook event
            }
            if (_usedEvents.Has(UsedEvents.Mouse))
            {
                hookM = AHookWin.MouseRaw_(_MouseHookProc);
            }
            if (_usedEvents.Has(UsedEvents.MouseEdgeMove))
            {
                _emDetector = new MouseTriggers.EdgeMoveDetector_();
            }
            //tested: don't need JIT-compiling.

            Api.SetEvent(_eventStartStop);

            while (Api.GetMessage(out var m) > 0)
            {
                Api.DispatchMessage(m);
            }

            //AOutput.Write("hooks thread ended");
            hookK?.Dispose();
            hookM?.Dispose();
            _emDetector = null;
            Api.SetEvent(_eventStartStop);
        }