Ejemplo n.º 1
0
 protected BaseShotter() {
     try {
         _keyboard = new KeyboardListener();
         _keyboard.KeyUp += OnKeyUp;
     } catch (Exception e) {
         AcToolsLogging.Write("Can’t set listener: " + e);
     }
 }
Ejemplo n.º 2
0
 public MemoryListener() {
     try {
         _keyboard = new KeyboardListener();
         _keyboard.KeyUp += OnKey;
     } catch (Exception e) {
         Logging.Error(e);
     }
 }
Ejemplo n.º 3
0
            public MemoryListener(CancellationTokenSource sharedCancellationTokenSource) {
                _sharedCancellationTokenSource = sharedCancellationTokenSource;

                try {
                    _keyboard = new KeyboardListener();
                    _keyboard.KeyUp += OnKeyUp;
                } catch (Exception e) {
                    Logging.Error(e);
                }

                AcSharedMemory.Instance.Start += OnStart;
            }
Ejemplo n.º 4
0
        private static void SubscribeInner(KeyboardListener instance) {
            if (Subscribed.Contains(instance)) return;

            Subscribed.Add(instance);
            if (_hookHandle == 0) {
                // ReSharper disable once RedundantDelegateCreation
                _hookProc = new User32.HookProc(KeyboardHookProc);

                // var id = Kernel32.LoadLibrary("User32");
                var id = Kernel32.GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName);
                var result = User32.SetWindowsHookEx(User32.WH_KEYBOARD_LL, _hookProc, id, 0);
                _hookHandle = result;

                AcToolsLogging.Write("Subscribed: " + result);
                if (result == 0) throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }
Ejemplo n.º 5
0
        private static void UnsubscribeInner(KeyboardListener instance) {
            if (Subscribed.Remove(instance) && Subscribed.Count == 0 && _hookHandle != 0) {
                var result = User32.UnhookWindowsHookEx(_hookHandle);
                _hookHandle = 0;
                _hookProc = null;

                AcToolsLogging.Write("Unsubscribed: " + result);
                if (result == 0) throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }