File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ namespace WindowTextExtractor . Extensions
4+ {
5+ public static class StringExtensions
6+ {
7+ public static string TrimEnd ( this string text , string value , StringComparison comparisonType = StringComparison . CurrentCulture )
8+ {
9+ var result = text ;
10+ while ( result . EndsWith ( value , comparisonType ) )
11+ {
12+ result = result . Substring ( 0 , result . Length - value . Length ) ;
13+ }
14+ return result ;
15+ }
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -218,8 +218,8 @@ public bool PreFilterMessage(ref Message m)
218218
219219 if ( ! element . Current . IsPassword && _isButtonTargetTextMouseDown )
220220 {
221- var text = element . GetTextFromConsole ( ) ?? element . GetTextFromWindow ( ) ;
222- txtContent . Text = text ;
221+ var text = element . GetTextFromWindow ( ) ;
222+ txtContent . Text = text == null ? "" : text . TrimEnd ( ) . TrimEnd ( Environment . NewLine ) ;
223223 txtContent . ScrollTextToEnd ( ) ;
224224 UpdateStatusBar ( ) ;
225225 }
Original file line number Diff line number Diff line change 8888 <ItemGroup >
8989 <Compile Include =" Extensions\AutomationElementExtensions.cs" />
9090 <Compile Include =" Extensions\ProcessExtensions.cs" />
91+ <Compile Include =" Extensions\StringExtensions.cs" />
9192 <Compile Include =" Extensions\TextBoxExtensions.cs" />
9293 <Compile Include =" Forms\AboutForm.cs" >
9394 <SubType >Form</SubType >
You can’t perform that action at this time.
0 commit comments