Example #1
0
 private GlobalHotkey()
 {
     // We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
     hookedLowLevelKeyboardProc = LowLevelKeyboardProc;
     // Set the hook
     hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);
 }
Example #2
0
 private GlobalHotkey()
 {
     // We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
     hookedLowLevelKeyboardProc = LowLevelKeyboardProc;
     // Set the hook
     hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);
 }
Example #3
0
 public KeyboardListener()
 {
     PreventDefault   = false;
     _keyProcDelegate = HookCallback;
     GC.KeepAlive(_keyProcDelegate);
     _hookId = InterceptKeys.SetHook(_keyProcDelegate);
 }
Example #4
0
 public KeyboardListener()
 {
     // Managed 환경의 delegate 인스턴스를 Native에 전달해서 GC가 구동된 이후 delegate 인스턴스가 정리되어버리기 때문에
     //이후에 native에서 삭제된 인스턴스의 delegate 값으로 호출하게 되면 "CallbackOnCollectedDelegate" 오류가 생긴다
     // 따라서 GC에 의해서 인스턴스가 정리되지 않도록 참조 포인터를 하나라도 유지하는 방법이 있으며, 이를 위해 코드 상단에 타입 멤버로 값을 가지고 있으면 된다.
     _LowLevelKeyboardProc = (InterceptKeys.LowLevelKeyboardProc)HookCallback;
     _HookId = InterceptKeys.SetHook(_LowLevelKeyboardProc);
 }
        public MainPlayerView()
        {
            InitializeComponent();

            AppSettings.RestoreSizePosition(this, Settings.Default.AppSettings);

            InterceptKeys.DoHook(_hookCallback = HookCallback);
        }
Example #6
0
 private static IntPtr SetHook(InterceptKeys.LowLevelKeyboardProc proc)
 {
     using (Process currentProcess = Process.GetCurrentProcess())
     {
         using (ProcessModule mainModule = currentProcess.MainModule)
             return(InterceptKeys.SetWindowsHookEx(13, proc, InterceptKeys.GetModuleHandle(mainModule.ModuleName), 0U));
     }
 }
        /// <summary>
        /// Creates global keyboard listener.
        /// </summary>
        public KeyboardListener()
        {
            // We have to store the HookCallback, so that it is not garbage collected runtime
            hookedLowLevelKeyboardProc = (InterceptKeys.LowLevelKeyboardProc)LowLevelKeyboardProc;

            // Set the hook
            hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);

            // Assign the asynchronous callback event
            hookedKeyboardCallbackAsync = new KeyboardCallbackAsync(KeyboardListener_KeyboardCallbackAsync);
        }
 /// <summary>
 /// Creates global keyboard listener.
 /// </summary>
 public KeyboardListener()
 {
     // Dispatcher thread handling the KeyDown/KeyUp events.
     this.dispatcher = Dispatcher.CurrentDispatcher;
     // We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
     hookedLowLevelKeyboardProc = (InterceptKeys.LowLevelKeyboardProc)LowLevelKeyboardProc;
     // Set the hook
     hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);
     // Assign the asynchronous callback event
     hookedKeyboardCallbackAsync = new KeyboardCallbackAsync(KeyboardListener_KeyboardCallbackAsync);
 }
Example #9
0
        /// <summary>
        ///     Creates global keyboard listener.
        /// </summary>
        internal KeyboardListener()
        {
            // Dispatcher thread handling the KeyDown/KeyUp events.
            _dispatcher = Dispatcher.CurrentDispatcher;

            // We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
            _hookProcDelegateToAvoidGC = LowLevelKeyboardProc;
            // Set the hook
            _hookId = InterceptKeys.SetHook(_hookProcDelegateToAvoidGC);

            // Assign the asynchronous callback event
            _hookedKeyboardCallbackAsync = KeyboardListener_KeyboardCallbackAsync;
        }
Example #10
0
        public KeyViewer()
        {
            InitializeComponent();
            KeyDown += (s, e) => { if (e.Key == Key.Escape)
                                   {
                                       Close();                                    /* messes up Cancel on save: App.Current.Shutdown();*/
                                   }
                                   e.Handled = true; };                            //tu:
            MouseLeftButtonDown += (s, e) => { DragMove(); e.Handled = true; };

            PreviewKeyDown += KeyViewer_PreviewKeyDn;
            PreviewKeyUp   += KeyViewer_PreviewKeyUp;

            InterceptKeys.DoHook(_hookCallback = HookCallback);
        }
Example #11
0
 public KeyboardListener()
 {
     _hook  = (InterceptKeys.LowLevelKeyboardProc)HookCallback;
     hookId = InterceptKeys.SetHook(_hook);
 }
Example #12
0
 private static extern IntPtr SetWindowsHookEx(
     int idHook,
     InterceptKeys.LowLevelKeyboardProc lpfn,
     IntPtr hMod,
     uint dwThreadId);
        public void Hook(bool getNextKeyOnly = false)
        {
            // We have to store the HookCallback, so that it is not garbage collected runtime
            hookedLowLevelKeyboardProc = (InterceptKeys.LowLevelKeyboardProc)LowLevelKeyboardProc;

            // Set the hook
            hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);

            // Assign the asynchronous callback event
            if (getNextKeyOnly)
                hookedKeyboardCallbackAsync = new KeyboardCallbackAsync(KeyboardListener_KeyboardCallbackAsyncOneKey);
            else
                hookedKeyboardCallbackAsync = new KeyboardCallbackAsync(KeyboardListener_KeyboardCallbackAsync);
        }
 public KeyboardListener()
 {
     proc   = HookCallback;//
     hookId = InterceptKeys.SetHook(proc);
     //hookId = InterceptKeys.SetHook((InterceptKeys.LowLevelKeyboardProc)HookCallback);
 }
Example #15
0
 public KeyboardListener()
 {
     // We have to store the LowLevelKeyboardProc, so that it is not garbage collected runtime
     hookedLowLevelKeyboardProc = LowLevelKeyboardProc;
     // Set the hook
     hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);
 }
Example #16
0
 static KeyHook()
 {
     proc = HookCallback;
 }
 public GlobalKeyboardListener()
 {
     callback = HookCallback;
     hookId   = InterceptKeys.SetHook(callback);
 }
Example #18
0
 public KeyboardListener()
 {
     hookedLowLevelKeyboardProc = (InterceptKeys.LowLevelKeyboardProc)LowLevelKeyboardProc;
     hookId = InterceptKeys.SetHook(hookedLowLevelKeyboardProc);
     hookedKeyboardCallbackAsync = new KeyboardCallbackAsync(KeyboardListener_KeyboardCallbackAsync);
 }
Example #19
0
 public void Dispose()
 {
     InterceptKeys.UnhookWindowsHookEx(hookId);
     _hook = null;
 }
Example #20
0
 public KeyboardListener()
 {
     llkp   = HookCallback;
     hookId = InterceptKeys.SetHook(llkp);
 }