Skip to content

Commit edd0317

Browse files
2.2.0.14 - Introduced a new tag that gets the title of the active window. Also added a new method method in MacroParser that strips away characters that are invalid in Windows filenames (except for the backslash character since we use that for the directory path).
1 parent 6c0ba91 commit edd0317

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

FormMain.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,7 @@ private void RunRegionCaptures()
26732673
if (_screenCapture.GetScreenImages(-1, region.X, region.Y, region.Width, region.Height, region.Mouse, region.ResolutionRatio, out Bitmap bitmap))
26742674
{
26752675
if (_screenCapture.TakeScreenshot(
2676-
path: FileSystem.CorrectDirectoryPath(region.Folder) + MacroParser.ParseTags(region.Name, region.Macro, -1, region.Format),
2676+
path: FileSystem.CorrectDirectoryPath(region.Folder) + MacroParser.ParseTags(region.Name, region.Macro, -1, region.Format, _screenCapture.ActiveWindowTitle),
26772677
format: region.Format,
26782678
component: -1,
26792679
screenshotType: ScreenshotType.Region,
@@ -2715,7 +2715,7 @@ private void RunScreenCaptures()
27152715
if (_screenCapture.GetScreenImages(screen.Component, 0, 0, 0, 0, false, screen.ResolutionRatio, out Bitmap bitmap))
27162716
{
27172717
if (_screenCapture.TakeScreenshot(
2718-
path: FileSystem.CorrectDirectoryPath(screen.Folder) + MacroParser.ParseTags(screen.Name, screen.Macro, screen.Component, screen.Format),
2718+
path: FileSystem.CorrectDirectoryPath(screen.Folder) + MacroParser.ParseTags(screen.Name, screen.Macro, screen.Component, screen.Format, _screenCapture.ActiveWindowTitle),
27192719
format: screen.Format,
27202720
component: screen.Component,
27212721
screenshotType: ScreenshotType.ActiveWindow,
@@ -2756,7 +2756,7 @@ private void RunScreenCaptures()
27562756
formScreen.ScreenDictionary[screen.Component].Bounds.Height, screen.Mouse, screen.ResolutionRatio, out Bitmap bitmap))
27572757
{
27582758
if (_screenCapture.TakeScreenshot(
2759-
path: FileSystem.CorrectDirectoryPath(screen.Folder) + MacroParser.ParseTags(screen.Name, screen.Macro, screen.Component, screen.Format),
2759+
path: FileSystem.CorrectDirectoryPath(screen.Folder) + MacroParser.ParseTags(screen.Name, screen.Macro, screen.Component, screen.Format, _screenCapture.ActiveWindowTitle),
27602760
format: screen.Format,
27612761
component: screen.Component,
27622762
screenshotType: ScreenshotType.Screen,

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.2.0.13")]
36-
[assembly: AssemblyFileVersion("2.2.0.13")]
35+
[assembly: AssemblyVersion("2.2.0.14")]
36+
[assembly: AssemblyFileVersion("2.2.0.14")]
3737
[assembly: NeutralResourcesLanguageAttribute("en-CA")]

app.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<assemblyIdentity
44
type="win32"
55
name="GavinKendall.AutoScreenCapture"
6-
version="2.2.0.13"/>
6+
version="2.2.0.14"/>
77
<asmv3:application>
88
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
99
<dpiAware>True/PM</dpiAware>

macro/MacroParser.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ public static class MacroParser
8080
/// <param name="name">The name of a region or screen when parsing the %name% tag.</param>
8181
/// <param name="macro">The macro to parse. A macro usually includes tags such as %count% and %date%.</param>
8282
/// <param name="format">The image format to use as an image file extension when parsing the %format% tag.</param>
83+
/// <param name="activeWindowTitle">The title of the active window.</param>
8384
/// <returns>A parsed macro containing the appropriate values of respective tags in the provided macro.</returns>
84-
public static string ParseTags(string name, string macro, int screenNumber, ImageFormat format)
85+
public static string ParseTags(string name, string macro, int screenNumber, ImageFormat format, string activeWindowTitle)
8586
{
8687
macro = !string.IsNullOrEmpty(name) ? macro.Replace(MacroTagSpec.Name, name) : macro;
8788
macro = macro.Replace(MacroTagSpec.ScreenNumber, screenNumber.ToString());
@@ -98,8 +99,28 @@ public static string ParseTags(string name, string macro, int screenNumber, Imag
9899
macro = macro.Replace(MacroTagSpec.Count, screenCapture.Count.ToString());
99100
macro = macro.Replace(MacroTagSpec.User, Environment.UserName);
100101
macro = macro.Replace(MacroTagSpec.Machine, Environment.MachineName);
102+
macro = macro.Replace(MacroTagSpec.Title, activeWindowTitle);
101103

102-
return macro;
104+
return StripInvalidWindowsCharacters(macro);
105+
}
106+
107+
/// <summary>
108+
/// Removes characters from a given string that are invalid to Windows.
109+
/// </summary>
110+
/// <param name="text">The string to parse.</param>
111+
/// <returns>A string that no longer contains invalid Windows characters.</returns>
112+
private static string StripInvalidWindowsCharacters(string text)
113+
{
114+
text = text.Replace("/", string.Empty);
115+
text = text.Replace(":", string.Empty);
116+
text = text.Replace("*", string.Empty);
117+
text = text.Replace("?", string.Empty);
118+
text = text.Replace("\"", string.Empty);
119+
text = text.Replace("<", string.Empty);
120+
text = text.Replace(">", string.Empty);
121+
text = text.Replace("|", string.Empty);
122+
123+
return text;
103124
}
104125
}
105126
}

macro/MacroTagCollection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public MacroTagCollection()
4141
Add(new MacroTag(MacroTagSpec.Count, "Number of screen capture cycles during the current screen capture session"));
4242
Add(new MacroTag(MacroTagSpec.User, "Name of logged in user (" + Environment.UserName + ")"));
4343
Add(new MacroTag(MacroTagSpec.Machine, "Name of machine being used (" + Environment.MachineName + ")"));
44+
Add(new MacroTag(MacroTagSpec.Title, "Title of the active window"));
4445
}
4546

4647
/// <summary>

macro/MacroTagSpec.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ public static class MacroTagSpec
2424
public static readonly string Count = "%count%";
2525
public static readonly string User = "%user%";
2626
public static readonly string Machine = "%machine%";
27+
public static readonly string Title = "%title%";
2728
}
2829
}

settings/Settings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace AutoScreenCapture
1313
public static class Settings
1414
{
1515
public static readonly string ApplicationName = "Auto Screen Capture";
16-
public static readonly string ApplicationVersion = "2.2.0.13";
16+
public static readonly string ApplicationVersion = "2.2.0.14";
1717
public static readonly string ApplicationCodename = "Dalek";
1818

1919
public static SettingCollection Application;
@@ -40,6 +40,11 @@ public static void Initialize()
4040
_versionCollection.Add(new Version("Dalek", "2.2.0.6")); // Can now select an existing label when applying a label
4141
_versionCollection.Add(new Version("Dalek", "2.2.0.7")); // Fixed upgrade path from old versions. Can now filter by Process Name
4242
_versionCollection.Add(new Version("Dalek", "2.2.0.8")); // Introduced %user% and %machine% macro tags
43+
_versionCollection.Add(new Version("Dalek", "2.2.0.9")); // Fixed upgrade path from older versions
44+
_versionCollection.Add(new Version("Dalek", "2.2.0.10")); // Fixed bug with %count% tag value when display is not available
45+
_versionCollection.Add(new Version("Dalek", "2.2.0.11")); // %screen% tag re-introduced
46+
_versionCollection.Add(new Version("Dalek", "2.2.0.12")); // Fixed bug with JPEG quality
47+
_versionCollection.Add(new Version("Dalek", "2.2.0.13")); // Fixed null reference when application starts at startup from Windows Startup folder
4348

4449
Application = new SettingCollection();
4550
Application.Filepath = FileSystem.SettingsFolder + FileSystem.ApplicationSettingsFile;

0 commit comments

Comments
 (0)