Skip to content

Commit b76344f

Browse files
committed
2.3.6.2 - New command line options -show and -hide. The application will no longer appear in Alt+Tab when interface is hidden.
1 parent 089dc3c commit b76344f

File tree

10 files changed

+135
-30
lines changed

10 files changed

+135
-30
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.1")]
36-
[assembly: AssemblyFileVersion("2.3.6.1")]
35+
[assembly: AssemblyVersion("2.3.6.2")]
36+
[assembly: AssemblyFileVersion("2.3.6.2")]
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.1"/>
6+
version="2.3.6.2"/>
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Auto Screen Capture by Gavin Kendall
2-
========================================================================================================================
32

43

54

65
Codename "Boombayah"
6+
2.3.6.2 New command line options -show and -hide. The application will no longer appear in Alt+Tab when interface is hidden.
77
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.
88
2.3.6.0 Fix to SMTP.
99
2.3.4.9 Region Select Options and Region Select / Clipboard / Floating Screenshot implemented.

interface/FormAbout.resx

Lines changed: 4 additions & 5 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.1 ("Boombayah")
121+
<value>Auto Screen Capture 2.3.6.2 ("Boombayah")
122122
Developed by Gavin Kendall (2008 - 2021)
123123

124124
SourceForge Project Site
@@ -128,14 +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.1
131+
<value>2.3.6.2
132132

133-
There was a bug with Keyboard Shortcuts that caused the application to crash. It's been fixed.
134-
135-
Also, by default, closing the application's main interface window will now hide the interface and keep the application running in the system tray so if you need to exit simply select the Exit option from the system tray icon menu.</value>
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>
136134
</data>
137135
<data name="richTextBoxChangelog.Text" xml:space="preserve">
138136
<value>Codename "Boombayah"
137+
2.3.6.2 New command line options -show and -hide. The application will no longer appear in Alt+Tab when interface is hidden.
139138
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.
140139
2.3.6.0 Fix to SMTP.
141140
2.3.4.9 Region Select Options and Region Select / Clipboard / Floating Screenshot implemented.

interface/main/FormMain-CommandLine.cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,37 @@ public partial class FormMain : Form
171171
/// </summary>
172172
internal const string REGEX_COMMAND_LINE_SAVE_SCREENSHOT_REFS_OFF = "^-saveScreenshotRefs=off$";
173173

174+
/// <summary>
175+
/// Regex for parsing the -show command.
176+
/// </summary>
177+
internal const string REGEX_COMMAND_LINE_SHOW = "^-show$";
178+
179+
/// <summary>
180+
/// Regex for parsing the -hide command.
181+
/// </summary>
182+
internal const string REGEX_COMMAND_LINE_HIDE = "^-hide$";
183+
184+
/// <summary>
185+
/// Parse commands issued externally via the command line.
186+
/// </summary>
187+
private void ParseCommandLineArguments()
188+
{
189+
// Parse commands issued externally via the command line.
190+
if (_fileSystem.FileExists(_fileSystem.CommandFile))
191+
{
192+
string[] args = _fileSystem.ReadFromFile(_fileSystem.CommandFile);
193+
194+
if (args.Length > 0)
195+
{
196+
ParseCommandLineArguments(args);
197+
}
198+
}
199+
else
200+
{
201+
_fileSystem.CreateFile(_fileSystem.CommandFile);
202+
}
203+
}
204+
174205
/// <summary>
175206
/// Parses the command line and processes the commands the user has chosen from the command line.
176207
/// </summary>
@@ -640,6 +671,66 @@ private void ParseCommandLineArguments(string[] args)
640671
_screenCapture.ApplicationError = true;
641672
}
642673
}
674+
675+
// -show
676+
if (Regex.IsMatch(arg, REGEX_COMMAND_LINE_SHOW))
677+
{
678+
_config.Settings.User.SetValueByKey("ShowSystemTrayIcon", true);
679+
680+
if (!_config.Settings.User.Save(_config.Settings, _fileSystem))
681+
{
682+
_screenCapture.ApplicationError = true;
683+
}
684+
685+
notifyIcon.Visible = true;
686+
687+
ShowInterface();
688+
689+
foreach (Trigger trigger in _formTrigger.TriggerCollection)
690+
{
691+
if (trigger.ActionType == TriggerActionType.ShowInterface)
692+
{
693+
trigger.Active = true;
694+
}
695+
}
696+
697+
BuildTriggersModule();
698+
699+
if (!_formTrigger.TriggerCollection.SaveToXmlFile(_config, _fileSystem, _log))
700+
{
701+
_screenCapture.ApplicationError = true;
702+
}
703+
}
704+
705+
// -hide
706+
if (Regex.IsMatch(arg, REGEX_COMMAND_LINE_HIDE))
707+
{
708+
_config.Settings.User.SetValueByKey("ShowSystemTrayIcon", false);
709+
710+
if (!_config.Settings.User.Save(_config.Settings, _fileSystem))
711+
{
712+
_screenCapture.ApplicationError = true;
713+
}
714+
715+
notifyIcon.Visible = false;
716+
717+
HideInterface();
718+
719+
foreach (Trigger trigger in _formTrigger.TriggerCollection)
720+
{
721+
if (trigger.ActionType == TriggerActionType.ShowInterface)
722+
{
723+
trigger.Active = false;
724+
}
725+
}
726+
727+
BuildTriggersModule();
728+
729+
if (!_formTrigger.TriggerCollection.SaveToXmlFile(_config, _fileSystem, _log))
730+
{
731+
_screenCapture.ApplicationError = true;
732+
}
733+
}
643734
}
644735

645736
if (_screenCapture.AutoStartFromCommandLine)

interface/main/FormMain-Schedules.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,7 @@ private void timerScheduledCapture_Tick(object sender, EventArgs e)
4545
HelpTip.Message = string.Empty;
4646
}
4747

48-
// Parse commands issued externally via the command line.
49-
if (_fileSystem.FileExists(_fileSystem.CommandFile))
50-
{
51-
string[] args = _fileSystem.ReadFromFile(_fileSystem.CommandFile);
52-
53-
if (args.Length > 0)
54-
{
55-
ParseCommandLineArguments(args);
56-
}
57-
}
58-
else
59-
{
60-
_fileSystem.CreateFile(_fileSystem.CommandFile);
61-
}
48+
ParseCommandLineArguments();
6249

6350
// Displays the next time screenshots are going to be captured
6451
// in the system tray icon's tool tip, the main interface, and information window.

interface/main/FormMain-Settings.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,6 @@ private void LoadSettings()
201201
checkBoxInitialScreenshot.Checked = Convert.ToBoolean(_config.Settings.User.GetByKey("TakeInitialScreenshot", _config.Settings.DefaultSettings.TakeInitialScreenshot).Value);
202202
_log.WriteDebugMessage("TakeInitialScreenshot = " + checkBoxInitialScreenshot.Checked);
203203

204-
notifyIcon.Visible = Convert.ToBoolean(_config.Settings.User.GetByKey("ShowSystemTrayIcon", _config.Settings.DefaultSettings.ShowSystemTrayIcon).Value);
205-
_log.WriteDebugMessage("ShowSystemTrayIcon = " + notifyIcon.Visible);
206-
207204
comboBoxScreenshotLabel.Text = _config.Settings.User.GetByKey("ScreenshotLabel", _config.Settings.DefaultSettings.ScreenshotLabel).Value.ToString();
208205
_log.WriteDebugMessage("ScreenshotLabel = " + comboBoxScreenshotLabel.Text);
209206

interface/main/FormMain.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

interface/main/FormMain.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ namespace AutoScreenCapture
3232
/// </summary>
3333
public partial class FormMain : Form
3434
{
35+
private bool _loaded = false;
36+
3537
// The "About Auto Screen Capture" form.
3638
private FormAbout _formAbout;
3739

@@ -168,6 +170,11 @@ private void FormMain_Load(object sender, EventArgs e)
168170

169171
HelpMessage(welcome);
170172

173+
ParseCommandLineArguments();
174+
175+
notifyIcon.Visible = Convert.ToBoolean(_config.Settings.User.GetByKey("ShowSystemTrayIcon", _config.Settings.DefaultSettings.ShowSystemTrayIcon).Value);
176+
_log.WriteDebugMessage("ShowSystemTrayIcon = " + notifyIcon.Visible);
177+
171178
// Start the scheduled capture timer.
172179
timerScheduledCapture.Interval = 1000;
173180
timerScheduledCapture.Enabled = true;
@@ -185,6 +192,29 @@ private void FormMain_Load(object sender, EventArgs e)
185192
RunTriggersOfConditionType(TriggerConditionType.ApplicationStartup);
186193
}
187194

195+
/// <summary>
196+
/// Set opacity to the appropriate value and taskbar appearance based on visibility.
197+
/// </summary>
198+
/// <param name="e"></param>
199+
protected override void OnVisibleChanged(EventArgs e)
200+
{
201+
if (_loaded && Visible)
202+
{
203+
Show();
204+
Opacity = 100;
205+
ShowInTaskbar = true;
206+
Focus();
207+
}
208+
else
209+
{
210+
Hide();
211+
Opacity = 0;
212+
ShowInTaskbar = false;
213+
}
214+
215+
base.OnVisibleChanged(e);
216+
}
217+
188218
/// <summary>
189219
/// When this form is closing we can either exit the application or just close this window.
190220
/// </summary>
@@ -353,8 +383,8 @@ private void ShowInterface()
353383

354384
PopulateLabelList();
355385

356-
Opacity = 100;
357-
ShowInTaskbar = true;
386+
_loaded = true;
387+
Visible = true;
358388

359389
// If the window is mimimized then show it when the user wants to open the window.
360390
if (WindowState == FormWindowState.Minimized)
@@ -382,8 +412,7 @@ private void HideInterface()
382412
{
383413
_log.WriteDebugMessage("Hiding interface");
384414

385-
Opacity = 0;
386-
ShowInTaskbar = false;
415+
Visible = false;
387416

388417
_log.WriteDebugMessage("Running triggers of condition type InterfaceHiding");
389418
RunTriggersOfConditionType(TriggerConditionType.InterfaceHiding);

settings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public void Load(FileSystem fileSystem)
230230
_versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.8")); // Signed assembly in attempt to satisfy anti-virus software.Fixed weird Exit bug.
231231
_versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.9")); // Region Select Options and Region Select / Clipboard / Floating Screenshot implemented.
232232
_versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.6.0")); // Fix to SMTP.
233+
_versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "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.
233234

234235
Application = new SettingCollection()
235236
{

0 commit comments

Comments
 (0)