Exemplo n.º 1
0
        public HotkeyHook()
        {
            this.hookedWindow = new HookedWindow();

            this.hookedWindow.KeyPressed += delegate(object _, HotkeyPressedEventArgs args)
            {
                KeyPressed?.Invoke(this, args);
            };
        }
Exemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Adds a window procedure callback to 'callback'. </summary>
        ///
        /// <param name="windowHandle"> Handle of the window. </param>
        /// <param name="callback">     The callback. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public static void AddWndProcCallback(IntPtr windowHandle, WndProcCallback callback)
        {
            //If we already have hooks associated with this windowHandle then just
            // add the callback
            if (ApplicationsHookedWindows.TryGetValue(windowHandle, out var hookedWindow))
            {
                hookedWindow.AttachCallback(callback);
                hookedWindow.OnClosed += HookedWindow_OnDestroyed;
            }
            else
            {
                hookedWindow = new HookedWindow(windowHandle, callback);
                ApplicationsHookedWindows[windowHandle] = hookedWindow;
            }
        }