Skip to content

Commit d7b8927

Browse files
2.2.0.17 - Replaced -lock command line argument with -passphrase and added logic around hashing the passphrase given from the command line.
1 parent 59eb0a7 commit d7b8927

File tree

2 files changed

+46
-48
lines changed

2 files changed

+46
-48
lines changed

FormMain.cs

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,14 @@ public partial class FormMain : Form
7070

7171
private const string REGEX_COMMAND_LINE_LIMIT = @"^-limit=(?<Limit>\d{1,7})$";
7272

73-
private const string REGEX_COMMAND_LINE_STOPAT =
74-
@"^-stopat=(?<Hours>\d{2}):(?<Minutes>\d{2}):(?<Seconds>\d{2})$";
73+
private const string REGEX_COMMAND_LINE_STOPAT = @"^-stopat=(?<Hours>\d{2}):(?<Minutes>\d{2}):(?<Seconds>\d{2})$";
7574

76-
private const string REGEX_COMMAND_LINE_STARTAT =
77-
@"^-startat=(?<Hours>\d{2}):(?<Minutes>\d{2}):(?<Seconds>\d{2})$";
75+
private const string REGEX_COMMAND_LINE_STARTAT = @"^-startat=(?<Hours>\d{2}):(?<Minutes>\d{2}):(?<Seconds>\d{2})$";
7876

79-
private const string REGEX_COMMAND_LINE_INTERVAL =
80-
@"^-interval=(?<Hours>\d{2}):(?<Minutes>\d{2}):(?<Seconds>\d{2})\.(?<Milliseconds>\d{3})$";
77+
private const string REGEX_COMMAND_LINE_INTERVAL = @"^-interval=(?<Hours>\d{2}):(?<Minutes>\d{2}):(?<Seconds>\d{2})\.(?<Milliseconds>\d{3})$";
78+
79+
private const string REGEX_COMMAND_LINE_PASSPHRASE = "^-passphrase=(?<Passphrase>.+)$";
8180

82-
private const string REGEX_COMMAND_LINE_LOCK = "^-lock$";
8381
private const string REGEX_COMMAND_LINE_HIDE_SYSTEM_TRAY_ICON = "^-hideSystemTrayIcon$";
8482

8583
/// <summary>
@@ -1226,7 +1224,7 @@ private void ParseCommandLineArguments(string[] args)
12261224

12271225
#endregion Default Values for Command Line Arguments/Options
12281226

1229-
Regex rgxCommandLineLock = new Regex(REGEX_COMMAND_LINE_LOCK);
1227+
Regex rgxCommandLinePassphrase = new Regex(REGEX_COMMAND_LINE_PASSPHRASE);
12301228
Regex rgxCommandLineLimit = new Regex(REGEX_COMMAND_LINE_LIMIT);
12311229
Regex rgxCommandLineInitial = new Regex(REGEX_COMMAND_LINE_INITIAL);
12321230
Regex rgxCommandLineCaptureInterval = new Regex(REGEX_COMMAND_LINE_INTERVAL);
@@ -1262,12 +1260,9 @@ private void ParseCommandLineArguments(string[] args)
12621260
if (rgxCommandLineCaptureInterval.IsMatch(args[i]))
12631261
{
12641262
int hours = Convert.ToInt32(rgxCommandLineCaptureInterval.Match(args[i]).Groups["Hours"].Value);
1265-
int minutes =
1266-
Convert.ToInt32(rgxCommandLineCaptureInterval.Match(args[i]).Groups["Minutes"].Value);
1267-
int seconds =
1268-
Convert.ToInt32(rgxCommandLineCaptureInterval.Match(args[i]).Groups["Seconds"].Value);
1269-
int milliseconds =
1270-
Convert.ToInt32(rgxCommandLineCaptureInterval.Match(args[i]).Groups["Milliseconds"].Value);
1263+
int minutes = Convert.ToInt32(rgxCommandLineCaptureInterval.Match(args[i]).Groups["Minutes"].Value);
1264+
int seconds = Convert.ToInt32(rgxCommandLineCaptureInterval.Match(args[i]).Groups["Seconds"].Value);
1265+
int milliseconds = Convert.ToInt32(rgxCommandLineCaptureInterval.Match(args[i]).Groups["Milliseconds"].Value);
12711266

12721267
numericUpDownHoursInterval.Value = hours;
12731268
numericUpDownMinutesInterval.Value = minutes;
@@ -1278,36 +1273,36 @@ private void ParseCommandLineArguments(string[] args)
12781273
if (rgxCommandLineScheduleStartAt.IsMatch(args[i]))
12791274
{
12801275
int hours = Convert.ToInt32(rgxCommandLineScheduleStartAt.Match(args[i]).Groups["Hours"].Value);
1281-
int minutes =
1282-
Convert.ToInt32(rgxCommandLineScheduleStartAt.Match(args[i]).Groups["Minutes"].Value);
1283-
int seconds =
1284-
Convert.ToInt32(rgxCommandLineScheduleStartAt.Match(args[i]).Groups["Seconds"].Value);
1276+
int minutes = Convert.ToInt32(rgxCommandLineScheduleStartAt.Match(args[i]).Groups["Minutes"].Value);
1277+
int seconds = Convert.ToInt32(rgxCommandLineScheduleStartAt.Match(args[i]).Groups["Seconds"].Value);
12851278

1286-
dateTimePickerScheduleStartAt.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
1287-
DateTime.Now.Day, hours, minutes, seconds);
1279+
dateTimePickerScheduleStartAt.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hours, minutes, seconds);
12881280

12891281
checkBoxScheduleStartAt.Checked = true;
12901282
}
12911283

12921284
if (rgxCommandLineScheduleStopAt.IsMatch(args[i]))
12931285
{
12941286
int hours = Convert.ToInt32(rgxCommandLineScheduleStopAt.Match(args[i]).Groups["Hours"].Value);
1295-
int minutes =
1296-
Convert.ToInt32(rgxCommandLineScheduleStopAt.Match(args[i]).Groups["Minutes"].Value);
1297-
int seconds =
1298-
Convert.ToInt32(rgxCommandLineScheduleStopAt.Match(args[i]).Groups["Seconds"].Value);
1287+
int minutes = Convert.ToInt32(rgxCommandLineScheduleStopAt.Match(args[i]).Groups["Minutes"].Value);
1288+
int seconds = Convert.ToInt32(rgxCommandLineScheduleStopAt.Match(args[i]).Groups["Seconds"].Value);
12991289

1300-
dateTimePickerScheduleStopAt.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
1301-
DateTime.Now.Day, hours, minutes, seconds);
1290+
dateTimePickerScheduleStopAt.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hours, minutes, seconds);
13021291

13031292
checkBoxScheduleStopAt.Checked = true;
13041293
}
13051294

1306-
string passphrase = Settings.User.GetByKey("StringPassphrase", defaultValue: string.Empty).Value.ToString();
1307-
1308-
if (rgxCommandLineLock.IsMatch(args[i]) && passphrase.Length > 0)
1295+
if (rgxCommandLinePassphrase.IsMatch(args[i]))
13091296
{
1310-
ScreenCapture.LockScreenCaptureSession = true;
1297+
string passphrase = rgxCommandLinePassphrase.Match(args[i]).Groups["Passphrase"].Value;
1298+
1299+
if (passphrase.Length > 0)
1300+
{
1301+
Settings.User.GetByKey("StringPassphrase", defaultValue: string.Empty).Value = Security.Hash(passphrase);
1302+
SaveSettings();
1303+
1304+
ScreenCapture.LockScreenCaptureSession = true;
1305+
}
13111306
}
13121307

13131308
if (rgxCommandLineHideSystemTrayIcon.IsMatch(args[i]))

settings/Settings.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public static class Settings
2222
public static VersionManager VersionManager;
2323
private static VersionCollection _versionCollection;
2424

25+
private const string CODENAME_CLARA = "Clara";
26+
private const string CODENAME_DALEK = "Dalek";
27+
2528
public static void Initialize()
2629
{
2730
_versionCollection = new VersionCollection();
@@ -30,24 +33,24 @@ public static void Initialize()
3033
_versionCollection.Add(new Version(ApplicationCodename, ApplicationVersion, isCurrentVersion: true));
3134

3235
// Older versions should be listed here.
33-
_versionCollection.Add(new Version("Clara", "2.1.8.2")); // Last version that introduced the Macro concept
34-
_versionCollection.Add(new Version("Dalek", "2.2.0.0")); // Support for unlimited number of screens
35-
_versionCollection.Add(new Version("Dalek", "2.2.0.1")); // Fixed empty window title bug
36-
_versionCollection.Add(new Version("Dalek", "2.2.0.2")); // Continue screen capture session when drive not available
37-
_versionCollection.Add(new Version("Dalek", "2.2.0.3")); // Changes to how we save screenshots
38-
_versionCollection.Add(new Version("Dalek", "2.2.0.4")); // More changes to how we save screenshots
39-
_versionCollection.Add(new Version("Dalek", "2.2.0.5")); // Fixes the changes to how we save screenshots
40-
_versionCollection.Add(new Version("Dalek", "2.2.0.6")); // Can now select an existing label when applying a label
41-
_versionCollection.Add(new Version("Dalek", "2.2.0.7")); // Fixed upgrade path from old versions. Can now filter by Process Name
42-
_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
48-
_versionCollection.Add(new Version("Dalek", "2.2.0.14")); // Introduced %title% tag
49-
_versionCollection.Add(new Version("Dalek", "2.2.0.15")); // Strip out backslash if it's in the active window title
50-
_versionCollection.Add(new Version("Dalek", "2.2.0.16")); // Stop timerPerformMaintenance when window is open and start it again when window is closed
36+
_versionCollection.Add(new Version(CODENAME_CLARA, "2.1.8.2")); // Last version that introduced the Macro concept
37+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.0")); // Support for unlimited number of screens
38+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.1")); // Fixed empty window title bug
39+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.2")); // Continue screen capture session when drive not available
40+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.3")); // Changes to how we save screenshots
41+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.4")); // More changes to how we save screenshots
42+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.5")); // Fixes the changes to how we save screenshots
43+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.6")); // Can now select an existing label when applying a label
44+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.7")); // Fixed upgrade path from old versions. Can now filter by Process Name
45+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.8")); // Introduced %user% and %machine% macro tags
46+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.9")); // Fixed upgrade path from older versions
47+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.10")); // Fixed bug with %count% tag value when display is not available
48+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.11")); // %screen% tag re-introduced
49+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.12")); // Fixed bug with JPEG quality
50+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.13")); // Fixed null reference when application starts at startup from Windows Startup folder
51+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.14")); // Introduced %title% tag
52+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.15")); // Strip out backslash if it's in the active window title
53+
_versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.16")); // Stop timerPerformMaintenance when window is open and start it again when window is closed
5154

5255
Application = new SettingCollection();
5356
Application.Filepath = FileSystem.SettingsFolder + FileSystem.ApplicationSettingsFile;

0 commit comments

Comments
 (0)