我用WM_GETTEXT得到的跟用GetWindowText一样都是标题 要怎么样才可以获得内容?

解决方案 »

  1.   

    你当WM_GETTEXT什么文字都能获得啊,而且你获得的句柄肯定是word主界面的句柄,而不是文字录入区的句柄
      

  2.   


    还是只得到标题阿
    IntPtr calculatorHandle = FindWindow("OpusApp", "Microsoft Word 文档.docx - Microsoft Word");SetForegroundWindow(calculatorHandle);
    int WM_GETTEXT = 0x0D;
    const int buffer_size = 1024*10;
    StringBuilder buffer = new StringBuilder(buffer_size);
    SendMessage(calculatorHandle, WM_GETTEXT, buffer_size, buffer);
    textBox1.Text = buffer.ToString();StringBuilder s = new StringBuilder(1024*10);
    int i = GetWindowText(calculatorHandle, s, s.Capacity);
    textBox1.Text += s.ToString();文本内容是123
    但是他返回的值是Microsoft Word 文档.docx - Microsoft WordMicrosoft Word 文档.docx - Microsoft Word
      

  3.   

    而且他的子框
    IntPtr aa = FindWindowEx(calculatorHandle, IntPtr.Zero, "MsoCommandBarDock", "MsoDockLeft");
                IntPtr bb = FindWindowEx(calculatorHandle, aa, "MsoCommandBarDock", "MsoDockRight");
                IntPtr cc = FindWindowEx(calculatorHandle, bb, "MsoCommandBarDock", "MsoDockTop");
                IntPtr dd = FindWindowEx(calculatorHandle, cc, "MsoCommandBarDock", "MsoDockBottom");
                IntPtr ee = FindWindowEx(calculatorHandle, dd, "_WwF", null);
                IntPtr ff = FindWindowEx(ee, IntPtr.Zero, "_WwB", "Microsoft Word 文档.docx");
                IntPtr jj = FindWindowEx(ff, IntPtr.Zero, "MsoCommandBar", "MSO Generic Control Container");
                IntPtr kk = FindWindowEx(ff, jj, "MsoCommandBar", "MSO Generic Control Container");
                IntPtr ll = FindWindowEx(ff, kk, "_WwG", "Microsoft Word 文档");
                IntPtr mm = FindWindowEx(ff, ll, "NUIScrollbar", "垂直");
                IntPtr nn = FindWindowEx(ff, mm, "_WwC", null);
                IntPtr oo = FindWindowEx(ff, nn, "_WwC", null);
                IntPtr pp = FindWindowEx(ff, oo, "NUIScrollbar", "水平");
                IntPtr qq = FindWindowEx(ff, kk, "_WwC", null);我也都找了也没有啊阿
      

  4.   

    我觉得,还是找WORD正在打开的那个文件吧
      

  5.   

    LIST 一个进程打开的文件
    http://www.codeproject.com/Articles/18975/Listing-Used-Files
      

  6.   

    http://stackoverflow.com/questions/7389757/get-text-from-an-edit-control-pure-win32-api
      

  7.   

    http://www.cnblogs.com/mextb1860/archive/2010/06/12/1757352.html
      

  8.   

    文本编辑器直接用WM_GETTEXT是可以得到呢-0-因为它的标题直接变成内容,但是word就不行呢-0-~还有求c#的c++完全没有学过阿-0- 
      

  9.   

    不明白~你这个是第3方的插件么?我要c#代码的-0-至于word其实只是一个那来说明用的-0-其实我是要打开另外一个不是我写的程序之后得到程序窗口里面的信息什么的-0-
      

  10.   

    不明白~你这个是第3方的插件么?我要c#代码的-0-至于word其实只是一个那来说明用的-0-其实我是要打开另外一个不是我写的程序之后得到程序窗口里面的信息什么的-0-那你一开始就问错问题了。重新发帖吧