资料收集站

SDL

Thursday
Jan 08th
Text size
  • Increase font size
  • Default font size
  • Decrease font size

用API取出当前IE窗口已经选中的文本信息字符串

uses  
     msHtml,  SHdocvw;  
 
var  
   I:  Integer;  
   ShellWindow:  IShellWindows;  
   IE:  IWebbrowser2;  
   Doc:  IHtmlDocument2;  
   TxtRange:  IHtmlTxtRange;  
   S:  string;  
   P:  PChar;  
begin  
   ShellWindow  :=  CoShellWindows.Create;  
   for  I  :=  0  to  ShellWindow.Count-1  do  
   begin  
       IE  :=  ShellWindow.Item(I)  as  IWebbrowser2;  
       if  IE  <>  nil  then  
       begin  
           GetMem(P,  MaxByte+1);  
           GetClassName(IE.HWND,  P,  MaxByte);  
           if  SameText(P,  'IEFrame')  then  
           begin  
               Doc  :=  IE.Document  as  IHtmlDocument2;  
               if  Doc.Selection  <>  nil  then  
               begin  
                   TxtRange  :=  Doc.Selection.CreateRange  as  IHtmlTxtRange;  
                   S  :=  TxtRange.Get_text;  
                   SHowMessage(S);  
               end;  
           end;  
           FreeMem(P);  
       end;  
   end;  
end;  
Comments (0)Add Comment

Write comment

busy
 

Google 搜索

在线用户

We have 111 guests online