zoukankan      html  css  js  c++  java
  • 获取任意进程的文本内容值

     1 using System.Reflection;
     2 
     3 [DllImport("user32.dll", EntryPoint="FindWindow")]
     4 public static extern int FindWindow (
     5 string lpClassName,
     6 string lpWindowName
     7 );
     8 
     9 [DllImport("user32.dll", EntryPoint="FindWindowEx")]
    10 public static extern int FindWindowEx (
    11 int hWnd1,
    12 int hWnd2,
    13 string lpsz1,
    14 string lpsz2
    15 );
    16 
    17 [DllImport("user32.dll", EntryPoint="SendMessage")]
    18 public static extern int SendMessage (
    19 int hwnd,
    20 int wMsg,
    21 int wParam,
    22 System.Text.StringBuilder lParam
    23 );
    24 
    25 private void button1_Click(object sender, System.EventArgs e)
    26 {
    27 int hwnd = FindWindow("notepad", null);
    28 hwnd = FindWindowEx(hwnd, 0, "Edit", null);
    29 System.Text.StringBuilder str = new System.Text.StringBuilder(255);
    30 SendMessage(hwnd, 0xD, str.Capacity, str);
    31 MessageBox.Show(str.ToString());
    32 }

     先获取所要窗口的句柄(你可用spy++查相关的参数)
    然后用GetWindowText这个API函数

  • 相关阅读:
    暑期测试训练3
    对于在线段树上修改整段区间的理解
    UVA 11090 判负圈问题
    ZOJ 2588 求割边问题
    POJ 1523 网络连通
    hdu 1163
    hdu 1703
    hdu 2577 模拟
    hdu 3836 强连通+缩点:加边构强连通
    hdu 2571
  • 原文地址:https://www.cnblogs.com/yomho/p/3966280.html
Copyright © 2011-2022 走看看