2121using System ;
2222using System . Drawing ;
2323using System . Windows . Forms ;
24+ using System . Text . RegularExpressions ;
2425
2526namespace AutoScreenCapture
2627{
@@ -70,7 +71,15 @@ private void EnableStartCapture()
7071
7172 groupBoxActiveWindowTitle . Enabled = true ;
7273 checkBoxActiveWindowTitle . Enabled = true ;
73- textBoxActiveWindowTitle . Enabled = true ;
74+
75+ groupBoxApplicationFocus . Enabled = true ;
76+ comboBoxProcessList . Enabled = true ;
77+ labelApplicationFocusDelayBefore . Enabled = true ;
78+ labelApplicationFocusDelayAfter . Enabled = true ;
79+ numericUpDownApplicationFocusDelayBefore . Enabled = true ;
80+ numericUpDownApplicationFocusDelayAfter . Enabled = true ;
81+ buttonApplicationFocusTest . Enabled = true ;
82+ buttonApplicationFocusRefresh . Enabled = true ;
7483 }
7584 else
7685 {
@@ -107,7 +116,15 @@ private void EnableStopScreenCapture()
107116
108117 groupBoxActiveWindowTitle . Enabled = false ;
109118 checkBoxActiveWindowTitle . Enabled = false ;
110- textBoxActiveWindowTitle . Enabled = false ;
119+
120+ groupBoxApplicationFocus . Enabled = false ;
121+ comboBoxProcessList . Enabled = false ;
122+ labelApplicationFocusDelayBefore . Enabled = false ;
123+ labelApplicationFocusDelayAfter . Enabled = false ;
124+ numericUpDownApplicationFocusDelayBefore . Enabled = false ;
125+ numericUpDownApplicationFocusDelayAfter . Enabled = false ;
126+ buttonApplicationFocusTest . Enabled = false ;
127+ buttonApplicationFocusRefresh . Enabled = false ;
111128 }
112129
113130 /// <summary>
@@ -186,15 +203,10 @@ private void TakeScreenshot(bool captureNow)
186203
187204 _screenCapture . ActiveWindowProcessName = _screenCapture . GetActiveWindowProcessName ( ) ;
188205
189- if ( ! string . IsNullOrEmpty ( _screenCapture . ActiveWindowTitle ) )
206+ // 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.
207+ if ( checkBoxActiveWindowTitle . Checked && ! ActiveWindowTitleMatchesText ( ) )
190208 {
191- // Do not continue if the active window title needs to be checked and the active window title
192- // does not contain the text defined in "Active Window Title Capture Text".
193- if ( checkBoxActiveWindowTitle . Checked && ! string . IsNullOrEmpty ( textBoxActiveWindowTitle . Text ) &&
194- ! _screenCapture . ActiveWindowTitle . ToLower ( ) . Contains ( textBoxActiveWindowTitle . Text . ToLower ( ) ) )
195- {
196- return ;
197- }
209+ return ;
198210 }
199211
200212 RunRegionCaptures ( ) ;
@@ -642,5 +654,35 @@ private void timerScreenCapture_Tick(object sender, EventArgs e)
642654 StopScreenCapture ( ) ;
643655 }
644656 }
657+
658+ private bool ActiveWindowTitleMatchesText ( )
659+ {
660+ try
661+ {
662+ if ( ! string . IsNullOrEmpty ( _screenCapture . ActiveWindowTitle ) && ! string . IsNullOrEmpty ( textBoxActiveWindowTitle . Text ) )
663+ {
664+ if ( radioButtonCaseSensitiveMatch . Checked )
665+ {
666+ return _screenCapture . ActiveWindowTitle . Contains ( textBoxActiveWindowTitle . Text ) ;
667+ }
668+ else if ( radioButtonCaseInsensitiveMatch . Checked )
669+ {
670+ return _screenCapture . ActiveWindowTitle . ToLower ( ) . Contains ( textBoxActiveWindowTitle . Text . ToLower ( ) ) ;
671+ }
672+ else if ( radioButtonRegularExpressionMatch . Checked )
673+ {
674+ return Regex . IsMatch ( _screenCapture . ActiveWindowTitle , textBoxActiveWindowTitle . Text ) ;
675+ }
676+ }
677+
678+ return false ;
679+ }
680+ catch ( Exception ex )
681+ {
682+ Log . WriteExceptionMessage ( "FormMain-ScreenCapture::ActiveWindowTitleMatchesText" , ex ) ;
683+
684+ return false ;
685+ }
686+ }
645687 }
646688}
0 commit comments