|
@@ -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;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|