public static string CaptureScreen() { string relativePath = @"Images\Screen_" + DateTime.Now.ToString("ddMMyy_HHmmss") + ".png"; string path = Path.Combine(@"..\..\Reports", relativePath); GUI_Utils.CreateDirectoryForFilePath(path, false); bool success = CaptureElement.CaptureAllScreen(path); if (!success) { return(null); } return(relativePath); }
/// <summary> /// store capture image to folder @path2FolderStore /// @fileName = @ElementType_@ElementName_@ddMMyy_HHmmss /// </summary> /// <param name="path2FolderStore"></param> /// <returns></returns> public bool Capture(string path2FolderStore) { string fileName = this.Attributes.ElementType + "_"; fileName += this.Attributes.DesignedName != "" ? GUI_Utils.NormalizeString(this.Attributes.DesignedName) : GUI_Utils.NormalizeString(this.Attributes.DesignedId); fileName += "_" + System.DateTime.Now.ToString("ddMMyy_HHmmss") + ".png"; string filePath = path2FolderStore + @"\" + fileName; //modified by @duongtd - 09/11 //hard code string encoded = CaptureElement.CaptureScreen( GetCurrentAutoElement().Current.BoundingRectangle, filePath); return(encoded != null); }