示例#1
0
        // ---------------

        #region TrackingForegroundWindowChange

        public static IntPtr StartTrackingForegroundWindowChange(Action onWindowChangeAction, out GCHandle gcHandle)
        {
            WinEventDelegate action = (hook, type, hwnd, idObject, child, thread, time) =>
            {
                onWindowChangeAction.Invoke();
            };

            gcHandle = GCHandle.Alloc(action);
            return(WinAPIDeclarations.SetWinEventHook((uint)Event.EVENT_SYSTEM_FOREGROUND,
                                                      (uint)Event.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, action, 0, 0, (uint)Event.WINEVENT_OUTOFCONTEXT));
        }
示例#2
0
 public static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax,
                                             IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, uint dwFlags);