/// <summary> /// Save snapshot zip /// </summary> /// <param name="ecId">ElementContext Id</param> /// <param name="path">The output file</param> /// <param name="bmp">The screenshot</param> /// <param name="focusedElementId">The ID of the element with the current focus</param> /// <param name="mode">The type of file being saved</param> /// <param name="otherProperties">Properties to add to the snapshot metadata</param> /// <param name="completenessMode">Mode to control selective removal of data from the output</param> public static void SaveSnapshotZip(string path, Guid ecId, int?focusedElementId, A11yFileMode mode, Dictionary <SnapshotMetaPropertyName, object> otherProperties = null, CompletenessMode completenessMode = CompletenessMode.Full) { var ec = DataManager.GetDefaultInstance().GetElementContext(ecId); using (FileStream str = File.Open(path, FileMode.Create)) using (Package package = ZipPackage.Open(str, FileMode.Create)) { if (completenessMode == CompletenessMode.Full) { SaveSnapshotFromElement(focusedElementId, mode, otherProperties, completenessMode, ec, package, ec.DataContext.RootElment); } else { using (A11yElement reducedRoot = SelectAction.GetDefaultInstance().POIElementContext.Element.GetScrubbedElementTree()) { SaveSnapshotFromElement(focusedElementId, mode, otherProperties, completenessMode, ec, package, reducedRoot); } } } }
/// <summary> /// Bring the main window of POI element to front /// </summary> public static void BringMainWindowOfPOIElementToFront() { try { var procId = SelectAction.GetDefaultInstance().POIElementContext.Element.ProcessId; Process proc = Process.GetProcessById(procId); proc.Refresh(); IntPtr handle = proc.MainWindowHandle; NativeMethods.FocusWindow(handle); ((IUIAutomationElement)SelectAction.GetDefaultInstance().POIElementContext.Element.PlatformObject).SetFocus(); } catch (ArgumentException) { } catch (COMException) { } catch (NullReferenceException) { } catch (InvalidOperationException) { } }
/// <summary> /// Draw rectangle around the selected element in the application /// </summary> public void MarkSelectedElement() { A11yElement ele = SelectAction.GetDefaultInstance().POIElementContext.Element; this.Highlighter.MarkSelectedElement(ele); }
/// <summary> /// Get the DataContext Mode of currently selected ElementContext /// </summary> /// <returns></returns> public static DataContextMode GetDataContextMode() { var ec = DataManager.GetDefaultInstance().GetElementContext(SelectAction.GetDefaultInstance().GetSelectedElementContextId().Value); return(ec.DataContext != null ? ec.DataContext.Mode : DataContextMode.Live); }