Skip to content

Commit b397f1f

Browse files
committed
2.3.6.3 - No Match option implemented for Active Window Title. Fixed visibility bug when no Triggers are available on startup.
1 parent b76344f commit b397f1f

16 files changed

+311
-73
lines changed

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.3.6.2")]
36-
[assembly: AssemblyFileVersion("2.3.6.2")]
35+
[assembly: AssemblyVersion("2.3.6.3")]
36+
[assembly: AssemblyFileVersion("2.3.6.3")]
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.3.6.2"/>
6+
version="2.3.6.3"/>
77
<asmv3:application>
88
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
99
<dpiAware>True/PM</dpiAware>

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Auto Screen Capture by Gavin Kendall
33

44

55
Codename "Boombayah"
6+
2.3.6.3 No Match option implemented for Active Window Title. Fixed visibility bug when no Triggers are available on startup.
67
2.3.6.2 New command line options -show and -hide. The application will no longer appear in Alt+Tab when interface is hidden.
78
2.3.6.1 Fix to Keyboard Shortcuts. Changed default trigger for closing window so interface will now hide on closing window instead of exiting to keep application running in system tray until Exit is selected from system tray icon menu.
89
2.3.6.0 Fix to SMTP.

interface/FormAbout.resx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="richTextBoxApplication.Text" xml:space="preserve">
121-
<value>Auto Screen Capture 2.3.6.2 ("Boombayah")
121+
<value>Auto Screen Capture 2.3.6.3 ("Boombayah")
122122
Developed by Gavin Kendall (2008 - 2021)
123123

124124
SourceForge Project Site
@@ -128,12 +128,13 @@ GitHub Project Site
128128
https://github.com/gavinkendall/autoscreen/</value>
129129
</data>
130130
<data name="richTextBoxReleaseNotes.Text" xml:space="preserve">
131-
<value>2.3.6.2
131+
<value>2.3.6.3
132132

133-
New command line option -show for showing the interface, enabling triggers with the ShowInterface action, and showing the system tray icon. New command line option -hide for hiding the interface, disabling triggers with the ShowInterface action, and hiding the system tray icon. The application will no longer appear in Alt+Tab when interface is hidden.</value>
133+
You can now do a "No Match" when comparing the provided text with the active window title. This comes with its own Trigger Action (Set Active Window Title As No Match) and command line option (-activeWindowTitleNoMatch).</value>
134134
</data>
135135
<data name="richTextBoxChangelog.Text" xml:space="preserve">
136136
<value>Codename "Boombayah"
137+
2.3.6.3 No Match option implemented for Active Window Title. Fixed visibility bug when no Triggers are available on startup.
137138
2.3.6.2 New command line options -show and -hide. The application will no longer appear in Alt+Tab when interface is hidden.
138139
2.3.6.1 Fix to Keyboard Shortcuts. Changed default trigger for closing window so interface will now hide on closing window instead of exiting to keep application running in system tray until Exit is selected from system tray icon menu.
139140
2.3.6.0 Fix to SMTP.
@@ -453,7 +454,7 @@ Twitter
453454
https://twitter.com/autoscreen2
454455

455456
YouTube Channel
456-
https://www.youtube.com/c/gavinkendall/</value>
457+
https://www.youtube.com/gavinkendall/</value>
457458
</data>
458459
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
459460
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">

interface/main/FormMain-CommandLine.cs

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ public partial class FormMain : Form
141141
/// </summary>
142142
internal const string REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE = "^-activeWindowTitle=(?<ActiveWindowTitle>.+)$";
143143

144+
/// <summary>
145+
/// Regex for parsing the -activeWindowTitleMatch command.
146+
/// </summary>
147+
internal const string REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_MATCH = "^-activeWindowTitleMatch=(?<ActiveWindowTitleMatch>.+)$"; // The command line option -activeWindowTitleMatch is the same as -activeWindowTitle (to maintain backwards compatibility with previous versions since -activeWindowTitle is the old command line option)
148+
149+
/// <summary>
150+
/// Regex for parsing the -activeWindowTitleNoMatch command.
151+
/// </summary>
152+
internal const string REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_NO_MATCH = "^-activeWindowTitleNoMatch=(?<ActiveWindowTitleNoMatch>.+)$";
153+
154+
/// <summary>
155+
/// Regex for parsing the -activeWindowTitleMatchType command.
156+
/// </summary>
157+
internal const string REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_MATCH_TYPE = @"^-activeWindowTitleMatchType=(?<ActiveWindowTitleMatchType>\d{1})$";
158+
144159
/// <summary>
145160
/// Regex for parsing the -applicationFocus command.
146161
/// </summary>
@@ -186,6 +201,11 @@ public partial class FormMain : Form
186201
/// </summary>
187202
private void ParseCommandLineArguments()
188203
{
204+
if (!_fileSystem.FileExists(_fileSystem.CommandFile))
205+
{
206+
_fileSystem.CreateFile(_fileSystem.CommandFile);
207+
}
208+
189209
// Parse commands issued externally via the command line.
190210
if (_fileSystem.FileExists(_fileSystem.CommandFile))
191211
{
@@ -196,10 +216,6 @@ private void ParseCommandLineArguments()
196216
ParseCommandLineArguments(args);
197217
}
198218
}
199-
else
200-
{
201-
_fileSystem.CreateFile(_fileSystem.CommandFile);
202-
}
203219
}
204220

205221
/// <summary>
@@ -584,7 +600,59 @@ private void ParseCommandLineArguments(string[] args)
584600
_config.Load(_fileSystem);
585601
}
586602

587-
SetActiveWindowTitle(activeWindowTitle);
603+
SetActiveWindowTitleAsMatch(activeWindowTitle);
604+
}
605+
}
606+
607+
// -activeWindowTitleMatch="x"
608+
if (Regex.IsMatch(arg, REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_MATCH))
609+
{
610+
string activeWindowTitle = Regex.Match(arg, REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_MATCH).Groups["ActiveWindowTitleMatch"].Value;
611+
612+
if (activeWindowTitle.Length > 0)
613+
{
614+
if (string.IsNullOrEmpty(_fileSystem.UserSettingsFile))
615+
{
616+
_config.Load(_fileSystem);
617+
}
618+
619+
SetActiveWindowTitleAsMatch(activeWindowTitle);
620+
}
621+
}
622+
623+
// -activeWindowTitleNoMatch="x"
624+
if (Regex.IsMatch(arg, REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_NO_MATCH))
625+
{
626+
string activeWindowTitle = Regex.Match(arg, REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_NO_MATCH).Groups["ActiveWindowTitleNoMatch"].Value;
627+
628+
if (activeWindowTitle.Length > 0)
629+
{
630+
if (string.IsNullOrEmpty(_fileSystem.UserSettingsFile))
631+
{
632+
_config.Load(_fileSystem);
633+
}
634+
635+
SetActiveWindowTitleAsNoMatch(activeWindowTitle);
636+
}
637+
}
638+
639+
if (Regex.IsMatch(arg, REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_MATCH_TYPE))
640+
{
641+
int.TryParse(Regex.Match(arg, REGEX_COMMAND_LINE_ACTIVE_WINDOW_TITLE_MATCH_TYPE).Groups["ActiveWindowTitleMatchType"].Value, out int activeWindowTitleMatchType);
642+
643+
switch (activeWindowTitleMatchType)
644+
{
645+
case 1:
646+
radioButtonCaseSensitiveMatch.Checked = true;
647+
break;
648+
649+
case 2:
650+
radioButtonCaseInsensitiveMatch.Checked = true;
651+
break;
652+
653+
case 3:
654+
radioButtonRegularExpressionMatch.Checked = true;
655+
break;
588656
}
589657
}
590658

interface/main/FormMain-Help.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ private void LoadHelpTips()
5454
_toolTip.SetToolTip(comboBoxFilterType, "Choose a type of filter. This could be a label or the title of an active window from an application that was captured during a session");
5555
_toolTip.SetToolTip(comboBoxFilterValue, "Select a filter value based on the chosen filter type. This will show you what days in the calendar are associated with the filter value");
5656
_toolTip.SetToolTip(buttonRefreshFilterValues, "Click this button to refresh the list of filter values");
57-
_toolTip.SetToolTip(checkBoxActiveWindowTitle, "You can specify what text should be used for comparing with the title of the active window");
57+
_toolTip.SetToolTip(checkBoxActiveWindowTitleComparisonCheck, "Compare the given text with the title of the active window and they should match");
58+
_toolTip.SetToolTip(checkBoxActiveWindowTitleComparisonCheckReverse, "Compare the given text with the title of the active window and they should not match");
5859
_toolTip.SetToolTip(radioButtonCaseSensitiveMatch, "The text comparison will be case sensitive so the active window title will need to match exactly with each lowercase and uppercase character");
5960
_toolTip.SetToolTip(radioButtonCaseInsensitiveMatch, "The text comparison will be case insensitive so the active window title can contain a mixture of lowercase and uppercase characters");
6061
_toolTip.SetToolTip(radioButtonRegularExpressionMatch, "The text comparison will match with the regular expression pattern entered in the above text input field");

interface/main/FormMain-Schedules.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ private void timerScheduledCapture_Tick(object sender, EventArgs e)
140140
}
141141
}
142142
}
143+
144+
if (_appStarted)
145+
{
146+
// We want to figure out the visibility for the system tray icon here so it doesn't appear too early if we happen to use -hide.
147+
notifyIcon.Visible = Convert.ToBoolean(_config.Settings.User.GetByKey("ShowSystemTrayIcon", _config.Settings.DefaultSettings.ShowSystemTrayIcon).Value);
148+
_log.WriteDebugMessage("ShowSystemTrayIcon = " + notifyIcon.Visible);
149+
150+
_log.WriteDebugMessage("Running triggers of condition type ApplicationStartup");
151+
RunTriggersOfConditionType(TriggerConditionType.ApplicationStartup);
152+
153+
// Okay the application started so we can set this back to false. I really hate doing this but for now it's easy to get
154+
// around the weird situation where an ApplicationStartup trigger needs to run after the command line options get parsed
155+
// (and one of thse options might be -hide which needs to disable triggers using the ShowInterface action).
156+
// For example we don't want any triggers showing the interface if we're starting the application with something like ...
157+
// autoscreen.exe -interval=00:00:05.000 -start -hide
158+
_appStarted = false;
159+
}
143160
}
144161
catch (Exception ex)
145162
{

interface/main/FormMain-ScreenCapture.cs

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ private void TakeScreenshot(bool captureNow)
173173

174174
_screenCapture.ActiveWindowProcessName = _screenCapture.GetActiveWindowProcessName();
175175

176-
// Do not continue if the active window title needs to be checked and the active window title does not contain the defined text or regex pattern.
177-
if (checkBoxActiveWindowTitle.Checked && !ActiveWindowTitleMatchesText())
176+
if (checkBoxActiveWindowTitleComparisonCheck.Checked && !ActiveWindowTitleMatchText())
177+
{
178+
return;
179+
}
180+
181+
if (checkBoxActiveWindowTitleComparisonCheckReverse.Checked && !ActiveWindowTitleDoesNotMatchText())
178182
{
179183
return;
180184
}
@@ -664,12 +668,14 @@ private void timerScreenCapture_Tick(object sender, EventArgs e)
664668
}
665669
}
666670

667-
private bool ActiveWindowTitleMatchesText()
671+
private bool ActiveWindowTitleMatchText()
668672
{
669673
try
670674
{
671675
if (!string.IsNullOrEmpty(_screenCapture.ActiveWindowTitle) && !string.IsNullOrEmpty(textBoxActiveWindowTitle.Text))
672676
{
677+
textBoxActiveWindowTitle.Text = textBoxActiveWindowTitle.Text.Trim();
678+
673679
if (radioButtonCaseSensitiveMatch.Checked)
674680
{
675681
return _screenCapture.ActiveWindowTitle.Contains(textBoxActiveWindowTitle.Text);
@@ -688,19 +694,51 @@ private bool ActiveWindowTitleMatchesText()
688694
}
689695
catch (Exception ex)
690696
{
691-
_log.WriteExceptionMessage("FormMain-ScreenCapture::ActiveWindowTitleMatchesText", ex);
697+
_log.WriteExceptionMessage("FormMain-ScreenCapture::ActiveWindowTitleMatchText", ex);
692698

693699
return false;
694700
}
695701
}
696702

697-
private void SetActiveWindowTitle(string activeWindowTitle)
703+
private bool ActiveWindowTitleDoesNotMatchText()
704+
{
705+
try
706+
{
707+
if (!string.IsNullOrEmpty(_screenCapture.ActiveWindowTitle) && !string.IsNullOrEmpty(textBoxActiveWindowTitle.Text))
708+
{
709+
textBoxActiveWindowTitle.Text = textBoxActiveWindowTitle.Text.Trim();
710+
711+
if (radioButtonCaseSensitiveMatch.Checked)
712+
{
713+
return !_screenCapture.ActiveWindowTitle.Contains(textBoxActiveWindowTitle.Text);
714+
}
715+
else if (radioButtonCaseInsensitiveMatch.Checked)
716+
{
717+
return !_screenCapture.ActiveWindowTitle.ToLower().Contains(textBoxActiveWindowTitle.Text.ToLower());
718+
}
719+
else if (radioButtonRegularExpressionMatch.Checked)
720+
{
721+
return !Regex.IsMatch(_screenCapture.ActiveWindowTitle, textBoxActiveWindowTitle.Text);
722+
}
723+
}
724+
725+
return false;
726+
}
727+
catch (Exception ex)
728+
{
729+
_log.WriteExceptionMessage("FormMain-ScreenCapture::ActiveWindowTitleDoesNotMatchText", ex);
730+
731+
return false;
732+
}
733+
}
734+
735+
private void SetActiveWindowTitleAsMatch(string activeWindowTitle)
698736
{
699737
if (string.IsNullOrEmpty(activeWindowTitle))
700738
{
701739
_config.Settings.User.SetValueByKey("ActiveWindowTitleCaptureCheck", false);
702740

703-
checkBoxActiveWindowTitle.Checked = false;
741+
checkBoxActiveWindowTitleComparisonCheck.Checked = false;
704742
}
705743
else
706744
{
@@ -709,7 +747,34 @@ private void SetActiveWindowTitle(string activeWindowTitle)
709747
_config.Settings.User.SetValueByKey("ActiveWindowTitleCaptureCheck", true);
710748
_config.Settings.User.SetValueByKey("ActiveWindowTitleCaptureText", activeWindowTitle);
711749

712-
checkBoxActiveWindowTitle.Checked = true;
750+
checkBoxActiveWindowTitleComparisonCheck.Checked = true;
751+
textBoxActiveWindowTitle.Text = activeWindowTitle;
752+
753+
_screenCapture.ActiveWindowTitle = activeWindowTitle;
754+
}
755+
756+
if (!_config.Settings.User.Save(_config.Settings, _fileSystem))
757+
{
758+
_screenCapture.ApplicationError = true;
759+
}
760+
}
761+
762+
private void SetActiveWindowTitleAsNoMatch(string activeWindowTitle)
763+
{
764+
if (string.IsNullOrEmpty(activeWindowTitle))
765+
{
766+
_config.Settings.User.SetValueByKey("ActiveWindowTitleNoMatchCheck", false);
767+
768+
checkBoxActiveWindowTitleComparisonCheckReverse.Checked = false;
769+
}
770+
else
771+
{
772+
activeWindowTitle = activeWindowTitle.Trim();
773+
774+
_config.Settings.User.SetValueByKey("ActiveWindowTitleNoMatchCheck", true);
775+
_config.Settings.User.SetValueByKey("ActiveWindowTitleCaptureText", activeWindowTitle);
776+
777+
checkBoxActiveWindowTitleComparisonCheckReverse.Checked = true;
713778
textBoxActiveWindowTitle.Text = activeWindowTitle;
714779

715780
_screenCapture.ActiveWindowTitle = activeWindowTitle;

interface/main/FormMain-Settings.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,11 @@ private void LoadSettings()
207207
checkBoxScreenshotLabel.Checked = Convert.ToBoolean(_config.Settings.User.GetByKey("ApplyScreenshotLabel", _config.Settings.DefaultSettings.ApplyScreenshotLabel).Value);
208208

209209
// Active Window Title
210-
checkBoxActiveWindowTitle.Checked = Convert.ToBoolean(_config.Settings.User.GetByKey("ActiveWindowTitleCaptureCheck", _config.Settings.DefaultSettings.ActiveWindowTitleCaptureCheck).Value);
210+
checkBoxActiveWindowTitleComparisonCheck.Checked = Convert.ToBoolean(_config.Settings.User.GetByKey("ActiveWindowTitleCaptureCheck", _config.Settings.DefaultSettings.ActiveWindowTitleCaptureCheck).Value);
211+
checkBoxActiveWindowTitleComparisonCheckReverse.Checked = Convert.ToBoolean(_config.Settings.User.GetByKey("ActiveWindowTitleNoMatchCheck", _config.Settings.DefaultSettings.ActiveWindowTitleNoMatchCheck).Value);
211212
textBoxActiveWindowTitle.Text = _config.Settings.User.GetByKey("ActiveWindowTitleCaptureText", _config.Settings.DefaultSettings.ActiveWindowTitleCaptureText).Value.ToString();
212213

213-
if (checkBoxActiveWindowTitle.Checked)
214+
if (checkBoxActiveWindowTitleComparisonCheck.Checked || checkBoxActiveWindowTitleComparisonCheckReverse.Checked)
214215
{
215216
textBoxActiveWindowTitle.Enabled = true;
216217
radioButtonCaseSensitiveMatch.Enabled = true;
@@ -279,7 +280,8 @@ private void SaveSettings()
279280
_config.Settings.User.GetByKey("ApplyScreenshotLabel", _config.Settings.DefaultSettings.ApplyScreenshotLabel).Value = checkBoxScreenshotLabel.Checked;
280281

281282
// Active Window Title
282-
_config.Settings.User.GetByKey("ActiveWindowTitleCaptureCheck", _config.Settings.DefaultSettings.ActiveWindowTitleCaptureCheck).Value = checkBoxActiveWindowTitle.Checked;
283+
_config.Settings.User.GetByKey("ActiveWindowTitleCaptureCheck", _config.Settings.DefaultSettings.ActiveWindowTitleCaptureCheck).Value = checkBoxActiveWindowTitleComparisonCheck.Checked;
284+
_config.Settings.User.GetByKey("ActiveWindowTitleNoMatchCheck", _config.Settings.DefaultSettings.ActiveWindowTitleNoMatchCheck).Value = checkBoxActiveWindowTitleComparisonCheckReverse.Checked;
283285
_config.Settings.User.GetByKey("ActiveWindowTitleCaptureText", _config.Settings.DefaultSettings.ActiveWindowTitleCaptureText).Value = textBoxActiveWindowTitle.Text.Trim();
284286

285287
if (radioButtonCaseSensitiveMatch.Checked)

0 commit comments

Comments
 (0)