void RunUIAutomation(string xllPath) { // NOTE: Add for separate UI Automation Thread _syncContextAuto = new WindowsFormsSynchronizationContext(); //_syncContextAuto = _syncContextMain; _windowWatcher = new WindowWatcher(xllPath); _formulaEditWatcher = new FormulaEditWatcher(_windowWatcher, _syncContextAuto); _popupListWatcher = new PopupListWatcher(_windowWatcher, _syncContextAuto); _windowWatcher.MainWindowChanged += OnMainWindowChanged; _popupListWatcher.SelectedItemChanged += OnSelectedItemChanged; _formulaEditWatcher.StateChanged += OnStateChanged; _windowWatcher.TryInitialize(); // NOTE: Add for separate UI Automation Thread Application.Run(); }
// This runs on the new thread we've created to do all the Automation stuff (_threadAuto) // It returns only after when the SyncContext.Complete() has been called (from the IntelliSenseDisplay.Dispose() below) void RunUIAutomation() { _syncContextAuto = new SingleThreadSynchronizationContext(); Logger.Monitor.Verbose("UIMonitor.RunUIAutomation installing watchers"); // Create and hook together the various watchers _windowWatcher = new WindowWatcher(_syncContextAuto); _formulaEditWatcher = new FormulaEditWatcher(_windowWatcher, _syncContextAuto); _popupListWatcher = new PopupListWatcher(_windowWatcher, _syncContextAuto); _excelToolTipWatcher = new ExcelToolTipWatcher(_windowWatcher, _syncContextAuto); // These are the events we're interested in for showing, hiding and updating the IntelliSense forms _popupListWatcher.SelectedItemChanged += _popupListWatcher_SelectedItemChanged; _formulaEditWatcher.StateChanged += _formulaEditWatcher_StateChanged; _excelToolTipWatcher.ToolTipChanged += _excelToolTipWatcher_ToolTipChanged; _windowWatcher.TryInitialize(); _syncContextAuto.RunOnCurrentThread(); }
// This runs on the new thread we've created to do all the Automation stuff (_threadAuto) // It returns only after when the SyncContext.Complete() has been called (from the IntelliSenseDisplay.Dispose() below) void RunUIAutomation() { _syncContextAuto = new SingleThreadSynchronizationContext(); Logger.Monitor.Verbose("UIMonitor.RunUIAutomation installing watchers"); // Create and hook together the various watchers _windowWatcher = new WindowWatcher(_syncContextAuto); _formulaEditWatcher = new FormulaEditWatcher(_windowWatcher, _syncContextAuto); _popupListWatcher = new PopupListWatcher(_windowWatcher, _syncContextAuto); _excelToolTipWatcher = new ExcelToolTipWatcher(_windowWatcher, _syncContextAuto); // These are the events we're interested in for showing, hiding and updating the IntelliSense forms // _windowWatcher.MainWindowChanged += _windowWatcher_MainWindowChanged; // _windowWatcher.SelectDataSourceWindowChanged += _windowWatcher_SelectDataSourceWindowChanged; _popupListWatcher.SelectedItemChanged += _popupListWatcher_SelectedItemChanged; _formulaEditWatcher.StateChanged += _formulaEditWatcher_StateChanged; _excelToolTipWatcher.ToolTipChanged += _excelToolTipWatcher_ToolTipChanged; _windowWatcher.TryInitialize(); _syncContextAuto.RunOnCurrentThread(); }