@@ -15,17 +15,13 @@ public partial class MainForm : Form, IMessageFilter
1515 private readonly int _messageId ;
1616 private bool _isButtonTargetTextMouseDown ;
1717 private bool _isButtonTargetPasswordMouseDown ;
18- private Cursor _targetTextCursor ;
19- private Cursor _targetPasswordCursor ;
2018 private string _64BitFilePath ;
2119
2220 public MainForm ( )
2321 {
2422 InitializeComponent ( ) ;
2523 _isButtonTargetTextMouseDown = false ;
2624 _isButtonTargetPasswordMouseDown = false ;
27- _targetTextCursor = new Cursor ( Properties . Resources . TargetText . Handle ) ;
28- _targetPasswordCursor = new Cursor ( Properties . Resources . TargetPassword . Handle ) ;
2925 _processId = Process . GetCurrentProcess ( ) . Id ;
3026 _messageId = NativeMethods . RegisterWindowMessage ( "WINDOW_TEXT_EXTRACTOR_HOOK" ) ;
3127 _64BitFilePath = "" ;
@@ -85,7 +81,6 @@ private void btnTargetText_MouseDown(object sender, MouseEventArgs e)
8581 if ( ! _isButtonTargetTextMouseDown )
8682 {
8783 _isButtonTargetTextMouseDown = true ;
88- Cursor . Current = _targetTextCursor ;
8984 if ( ! TopMost )
9085 {
9186 SendToBack ( ) ;
@@ -98,7 +93,6 @@ private void btnTargetPassword_MouseDown(object sender, MouseEventArgs e)
9893 if ( ! _isButtonTargetPasswordMouseDown )
9994 {
10095 _isButtonTargetPasswordMouseDown = true ;
101- Cursor . Current = _targetPasswordCursor ;
10296 if ( ! TopMost )
10397 {
10498 SendToBack ( ) ;
@@ -173,7 +167,7 @@ public bool PreFilterMessage(ref Message m)
173167 {
174168 _isButtonTargetTextMouseDown = false ;
175169 _isButtonTargetPasswordMouseDown = false ;
176- Cursor . Current = Cursors . Default ;
170+ NativeMethods . SetCursor ( Cursors . Default . Handle ) ;
177171 if ( ! TopMost )
178172 {
179173 BringToFront ( ) ;
@@ -184,6 +178,18 @@ public bool PreFilterMessage(ref Message m)
184178 {
185179 try
186180 {
181+ if ( _isButtonTargetTextMouseDown )
182+ {
183+ NativeMethods . SetCursor ( Properties . Resources . TargetText . Handle ) ;
184+ }
185+ else if ( _isButtonTargetPasswordMouseDown )
186+ {
187+ NativeMethods . SetCursor ( Properties . Resources . TargetPassword . Handle ) ;
188+ }
189+ else
190+ {
191+ NativeMethods . SetCursor ( Cursors . Default . Handle ) ;
192+ }
187193 var cursorPosition = System . Windows . Forms . Cursor . Position ;
188194 var element = AutomationElement . FromPoint ( new System . Windows . Point ( cursorPosition . X , cursorPosition . Y ) ) ;
189195 if ( element != null && element . Current . ProcessId != _processId )
0 commit comments