Пример #1
0
        private void TryFindRenderingDialog(object state)
        {
            var desktopHwnds = EnumerateOpenedWindows.GetDesktopWindows();

            foreach (var hwnd1 in desktopHwnds)
            {
                uint windowProcessId;
                EnumerateOpenedWindows.GetWindowThreadProcessId(hwnd1, out windowProcessId);
                if (this.workerProcess.Id != windowProcessId)
                {
                    continue;
                }

                var windowText = EnumerateOpenedWindows.GetWindowText(hwnd1);
                if (windowText.Contains("Rendering"))
                {
                    var handles = EnumerateOpenedWindows.GetAllChildrenWindowHandles(hwnd1, long.MaxValue);
                    foreach (var ctrlHwnd in handles)
                    {
                        // ReSharper disable once InconsistentNaming
                        const int GWL_ID    = -12;
                        var       controlId = EnumerateOpenedWindows.GetWindowLongPtr(ctrlHwnd, GWL_ID);
                        if (controlId.ToInt32() == 0x544) // 0x544 corresponds to progressText label near rendering progress
                        {
                            this.progressLabelHwnd = ctrlHwnd;
                            this.findRenderDialogTimer?.Dispose();
                            this.findRenderDialogTimer = null;

                            this.StartWatchProgressTimer();
                        }
                    }
                }
            }
        }
Пример #2
0
        private void TryFindRenderingDialog(object state)
        {
            if (!this.findMutex.WaitOne(TimeSpan.FromMilliseconds(100)))
            {
                return;
            }

            try
            {
                var desktopHwnds = EnumerateOpenedWindows.GetDesktopWindows();

                foreach (var hwnd1 in desktopHwnds)
                {
                    uint windowProcessId;
                    EnumerateOpenedWindows.GetWindowThreadProcessId(hwnd1, out windowProcessId);
                    if (this.workerProcess.Id != windowProcessId)
                    {
                        continue;
                    }

                    var windowText = EnumerateOpenedWindows.GetWindowText(hwnd1);
                    if (windowText.Contains("Rendering"))
                    {
                        var handles = EnumerateOpenedWindows.GetAllChildrenWindowHandles(hwnd1, long.MaxValue);
                        foreach (var ctrlHwnd in handles)
                        {
                            // ReSharper disable once InconsistentNaming
                            const int GWL_ID    = -12;
                            var       controlId = EnumerateOpenedWindows.GetWindowLongPtr(ctrlHwnd, GWL_ID);
                            if (controlId.ToInt32() == 0x544)
                            // 0x544 corresponds to progressText label near rendering progress
                            {
                                this.progressLabelHwnd = ctrlHwnd;
                                this.findRenderDialogTimer?.Dispose();
                                this.findRenderDialogTimer = null;

                                this.StartWatchProgressTimer();
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Trace.TraceError(exc.Message);
            }
            finally
            {
                this.findMutex.ReleaseMutex();
            }
        }