Ejemplo n.º 1
0
 internal static extern IntPtr SetWinEventHook(
     AccessibleEvents eventMin,              //Specifies the event constant for the
     //lowest event value in the range of events that are
     //handled by the hook function. This parameter can
     //be set to EVENT_MIN to indicate the
     //lowest possible event value.
     AccessibleEvents eventMax,              //Specifies the event constant for the highest event
     //value in the range of events that are handled
     //by the hook function. This parameter can be set
     //to EVENT_MAX to indicate the highest possible
     //event value.
     IntPtr eventHookAssemblyHandle,                 //Handle to the DLL that contains the hook
     //function at lpfnWinEventProc, if the
     //WINEVENT_INCONTEXT flag is specified in the
     //dwFlags parameter. If the hook function is not
     //located in a DLL, or if the WINEVENT_OUTOFCONTEXT
     //flag is specified, this parameter is NULL.
     WinEventProc eventHookHandle,       //Pointer to the event hook function.
     //For more information about this function
     uint processId,                     //Specifies the ID of the process from which the
     //hook function receives events. Specify zero (0)
     //to receive events from all processes on the
     //current desktop.
     uint threadId,                      //Specifies the ID of the thread from which the
     //hook function receives events.
     //If this parameter is zero, the hook function is
     //associated with all existing threads on the
     //current desktop.
     SetWinEventHookParameter parameterFlags             //Flag values that specify the location
     //of the hook function and of the events to be
     //skipped. The following flags are valid:
     );
Ejemplo n.º 2
0
        public static void CheckProcessEvent(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            IntPtr m_hhook;

            winEventProc = new WinEventDelegate(WinEventProc);
            var handle = SetWinEventHook((uint)EventContants.EVENT_SYSTEM_FOREGROUND, (uint)EventContants.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero,
                                         winEventProc, 0, 0, (uint)(SetWinEventHookParameter.WINEVENT_OUTOFCONTEXT | SetWinEventHookParameter.WINEVENT_SKIPOWNPROCESS));

            m_hhook = SetWinEventHook((uint)EventContants.EVENT_SYSTEM_FOREGROUND, (uint)EventContants.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, winEventProc, 0, 0,
                                      (uint)(SetWinEventHookParameter.WINEVENT_OUTOFCONTEXT));
        }
 internal static extern IntPtr SetWinEventHook(AccessibleEvents eventMin, //Specifies the event constant for the lowest event value in the range of events that are handled by the hook function. This parameter can be set to EVENT_MIN to indicate the lowest possible event value.
                                               AccessibleEvents eventMax, //Specifies the event constant for the highest event value in the range of events that are handled by the hook function. This parameter can be set to EVENT_MAX to indicate the highest possible event value.
                                               IntPtr eventHookAssemblyHandle, //Handle to the DLL that contains the hook function at lpfnWinEventProc, if the WINEVENT_INCONTEXT flag is specified in the dwFlags parameter. If the hook function is not located in a DLL, or if the WINEVENT_OUTOFCONTEXT flag is specified, this parameter is NULL.
                                               WinEventProc eventHookHandle, //Pointer to the event hook function. For more information about this function
                                               uint processId, //Specifies the ID of the process from which the hook function receives events. Specify zero (0) to receive events from all processes on the current desktop.
                                               uint threadId, //Specifies the ID of the thread from which the hook function receives events. If this parameter is zero, the hook function is associated with all existing threads on the current desktop.
                                               SetWinEventHookParameter parameterFlags //Flag values that specify the location of the hook function and of the events to be skipped. The following flags are valid:
     );