当前位置:编程学习 > C#/ASP.NET >>

c# WM_GETTEXT怎么获得word的内容

我用WM_GETTEXT得到的跟用GetWindowText一样都是标题 要怎么样才可以获得内容? --------------------编程问答-------------------- 你当WM_GETTEXT什么文字都能获得啊,而且你获得的句柄肯定是word主界面的句柄,而不是文字录入区的句柄 --------------------编程问答--------------------
引用 1 楼 bdmh 的回复:
你当WM_GETTEXT什么文字都能获得啊,而且你获得的句柄肯定是word主界面的句柄,而不是文字录入区的句柄


还是只得到标题阿
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
--------------------编程问答-------------------- 而且他的子框
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);

我也都找了也没有啊阿 --------------------编程问答-------------------- 不要沉啊-0-找了点资料~好像说要跟进程内存有关系啥的 求大神说明来个例子阿 --------------------编程问答-------------------- 我觉得,还是找WORD正在打开的那个文件吧 --------------------编程问答--------------------
引用 5 楼 rtdb 的回复:
我觉得,还是找WORD正在打开的那个文件吧

找了阿-,-只出现标题 --------------------编程问答-------------------- LIST 一个进程打开的文件
http://www.codeproject.com/Articles/18975/Listing-Used-Files
--------------------编程问答-------------------- http://stackoverflow.com/questions/7389757/get-text-from-an-edit-control-pure-win32-api --------------------编程问答-------------------- http://www.cnblogs.com/mextb1860/archive/2010/06/12/1757352.html --------------------编程问答--------------------
引用 9 楼 hwenycocodq520 的回复:
http://www.cnblogs.com/mextb1860/archive/2010/06/12/1757352.html

文本编辑器直接用WM_GETTEXT是可以得到呢-0-因为它的标题直接变成内容,但是word就不行呢-0-~还有求c#的c++完全没有学过阿-0-  --------------------编程问答-------------------- 等有经验的来解决吧,没有这方面经验 --------------------编程问答--------------------
引用 7 楼 rtdb 的回复:
LIST 一个进程打开的文件
http://www.codeproject.com/Articles/18975/Listing-Used-Files

不明白~你这个是第3方的插件么?我要c#代码的-0-至于word其实只是一个那来说明用的-0-其实我是要打开另外一个不是我写的程序之后得到程序窗口里面的信息什么的-0- --------------------编程问答--------------------
引用 11 楼 hwenycocodq520 的回复:
等有经验的来解决吧,没有这方面经验
--------------------编程问答--------------------
引用 12 楼 solicitous 的回复:
Quote: 引用 7 楼 rtdb 的回复:

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

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


那你一开始就问错问题了。重新发帖吧
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,