///////////////////////////////////////////////////////////////////////////////////////////////// // // HandleEventOnUIThread() // // This is invoked on the main UI thread by the sample UIA event handler when a focus // change occurs. (The event handler itself runs on a background MTA created by UIA.) // ///////////////////////////////////////////////////////////////////////////////////////////////// private void HandleEventOnUIThread(string strName, Rectangle rectBounding) { _highlight.HighlightRect(rectBounding); if (_synth != null) { _synth.SpeakAsyncCancelAll(); _synth.SpeakAsync(strName); } }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // HighlightLink() // // Highlight the location of a hyperlink in the browser window on the screen. // // Runs on the background thread. // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void HighlightLinkInternal(IUIAutomationElement elementLink, bool fUseCache) { try { tagRECT rect = elementLink.CurrentBoundingRectangle; Rectangle rectHighlight = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); _highlight.HighlightRect(rectHighlight); } catch { // If an exception is throw trying to access the element, do nothing. This will // occur if the element no longer exists, (eg the browser window has been closed.) } }