[WinApi] C#获取其他窗口文本框内容
2021-03-10 04:28
标签:pre winapi api send dstat text sage import 句柄 声明部分: 函数部分: [WinApi] C#获取其他窗口文本框内容 标签:pre winapi api send dstat text sage import 句柄 原文地址:https://www.cnblogs.com/dongshenjun/p/12708144.htmlconst int WM_GETTEXT = 0x000D;
const int WM_GETTEXTLENGTH = 0x000E;
[DllImport("user32.dll", EntryPoint = "SendMessageA")]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, Byte[] lParam);
[DllImport("user32.dll", EntryPoint="SendMessageA")]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
IntPtr mwh = FindMainWindowHandle("窗口名称", 100, 25); //主窗口句柄
IntPtr HwndStatue = FindWindowEx(mwh, IntPtr.Zero, "Edit", null); //文本框句柄
if (HwndStatue != IntPtr.Zero)
{
int TextLen;
TextLen = SendMessage(HwndStatue, WM_GETTEXTLENGTH, 0, 0);
Byte[] byt = new Byte[TextLen];
SendMessage(HwndStatue, WM_GETTEXT, TextLen + 1, byt);
string str = Encoding.Default.GetString(byt);
}
文章标题:[WinApi] C#获取其他窗口文本框内容
文章链接:http://soscw.com/index.php/essay/62601.html