首页  编辑  

返回IE的当权选择的内容

Tags: /超级猛料/OS.操作系统/IE.扩展/页面控制和交互/   Date Created:

...get selected text from IE window?

Author: Zilvinas Ledas  

Homepage: http://mokslas.liux.lt

Ref URL: http://www.swissdelphicenter.ch/torry/showcode.php?id=1759

uses

 SHDocVw_TLB; // http://www.euromind.com/iedelphi if don't have that unit

function GetSelectedIEtext: string;

var

 x: Integer;

 Sw: IShellWindows;

 IE: HWND;

begin

 IE := FindWindow('IEFrame', nil);

 sw := CoShellWindows.Create;

 for x := SW.Count - 1 downto 0 do

   if (Sw.Item(x) as IWebbrowser2).hwnd = IE then begin

     Result := variant(Sw.Item(x)).Document.Selection.createRange.Text;

     break;

   end;

end;