liuyuqi-dellpc 1 year ago
parent
commit
fd1c94e3c0
1 changed files with 3 additions and 2 deletions
  1. 3 2
      GetInputText/Pages/MainForm.cs

+ 3 - 2
GetInputText/Pages/MainForm.cs

@@ -16,6 +16,7 @@ namespace GetInputText
         public MainForm()
         {
             InitializeComponent();
+            GetTextFromForegroundWindow();
         }
 
         const int WM_GETTEXT = 0x000D;
@@ -34,7 +35,7 @@ namespace GetInputText
         /// 全局监听激活的应用输入框的内容
         /// </summary>
         /// <param name="hWnd"></param>
-        public void GetTextFromWindow()
+        public void GetTextFromForegroundWindow()
         {
             IntPtr hWnd = GetForegroundWindow();
             int len = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0);
@@ -48,7 +49,7 @@ namespace GetInputText
                 {
                     this.tbContent.Text = text;
                 }
-            }   
+            }
         }
     }
 }