我在网页上按了一个选中一段文字,按了一个键后,用sendmessage如何获取这段文字,发送到我得textbox,谢谢

解决方案 »

  1.   

    JAVASCRIPT:textbox.value=document.select()
    不知道是不是document.select
      

  2.   

    document.selection.createRange().text;
      

  3.   

    <input type=button value=弹出你选中的文字 onclick="alert(document.selection.createRange().text)">
      

  4.   

    不是阿,我是winform的应用程序,主要是在挂上鼠标,键盘之后,用鼠标选中一段文字,按了指定建后,将网页上选中的文字送入我一个string变量
      

  5.   

    刚刚写了一个 //using SHDocVw;  需要添加引用 COM:MicroSoft Internet Control
    //using mshtml; 需要添加引用 COM:MicroSoft HTML Object Libary
    //using System.Runtime.InteropServices; // 调用:textBox1.Text=GetSelectedIEtext(); [DllImport("user32", EntryPoint="FindWindow")] 
    public static extern int FindWindowA(string lpClassName, string lpWindowName); /// <summary>
    /// 获取网页鼠标选择文本内容,只支持IE
    /// </summary>
    /// <returns></returns>
    public static string GetSelectedIEtext()
    {
    int ieHwnd=FindWindowA("IEFrame",null);
    IShellWindows sw=new ShellWindowsClass();
    string res=null;
    for (int i=sw.Count-1;i>=0;i--)
    {
    try
    {
    SHDocVw.IWebBrowser2 ib=sw.Item(i) as SHDocVw.IWebBrowser2;
    if(((SHDocVw.IWebBrowser2)sw.Item(i)).HWND==ieHwnd)
    {
    mshtml.IHTMLTxtRange txt=((HTMLDocumentClass)ib.Document).selection.createRange() as IHTMLTxtRange;
    res=txt.text;
    break;
    }
    }
    catch
    {
    res=null;
    }

    }
    return res;
    }