Пример #1
0
        private void ApplicationStatus(WindowInfoObject wio, EnumApplicationEvents appEvent)
        {
            var timeStamp = DateTime.Now;

            wio.AppTitle = appEvent == EnumApplicationEvents.CLOSED ? wio.AppTitle : WindowHookHelper.GetWindowText(wio.HWnd);
            wio.AppPath  = appEvent == EnumApplicationEvents.CLOSED ? wio.AppPath : WindowHookHelper.GetAppPath(wio.HWnd);
            wio.AppName  = appEvent == EnumApplicationEvents.CLOSED ? wio.AppName : WindowHookHelper.GetAppDescription(wio.AppPath);
            OnAppWindowChange?.Invoke(null, new ApplicationHookEvenArgs()
            {
                WindowInfo = wio, Events = appEvent
            });
        }
        private void pqm_OnJobStatusChange(object sender, PrintJobChangeEventArgs e)
        {
            if ((e.JobStatus & JOBSTATUS.JOB_STATUS_SPOOLING) == JOBSTATUS.JOB_STATUS_SPOOLING &&
                e.JobInfo != null)
            {
                var    hWnd     = WindowHookHelper.GetActiveWindowHandle();
                string appTitle = WindowHookHelper.GetWindowText(hWnd);
                string appName  = WindowHookHelper.GetAppDescription(WindowHookHelper.GetAppPath(hWnd));

                var printEvent = new PrintEventData
                {
                    JobName       = e.JobInfo.JobName,
                    JobSize       = e.JobInfo.JobSize,
                    EventDateTime = DateTime.Now,
                    Pages         = e.JobInfo.NumberOfPages,
                    PrinterName   = ((PrintQueueHook)sender).SpoolerName
                };

                Task.Run(() => OnPrintEvent?.Invoke(null, new PrintHookEventArgs {
                    EventData = printEvent
                }));
            }
        }