Copiando a URL do Explorer

 

Confira as funções necessárias para se copiar a URL do Explorer:

 

Function GetText(WindowHandle: hwnd):string;

var

  txtLength : integer;

  buffer: string;

begin

   TxtLength := SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0);

   txtlength := txtlength + 1;

   setlength (buffer, txtlength);

   sendmessage (WindowHandle,wm_gettext, txtlength, longint(@buffer[1]));

   result := buffer;

end;

 

function GetURL:string;

var

ie,toolbar,combo,

comboboxex,edit,

worker,toolbarwindow:hwnd;

  begin

   ie := FindWindow(pchar('IEFrame'),nil);

   worker := FindWindowEx(ie,0,'WorkerA',nil);

   toolbar := FindWindowEx(worker,0,'rebarwindow32',nil);

   comboboxex := FindWindowEx(toolbar, 0, 'comboboxex32', nil);

   combo := FindWindowEx(comboboxex,0,'ComboBox',nil);

   edit := FindWindowEx(combo,0,'Edit',nil);

   toolbarwindow := FindWindowEx(comboboxex, 0, 'toolbarwindow32', nil);

   result := GetText(edit);

end;

 

A URL fica armazenada em GetURL, no nosso exemplo utilizamos o comando showmessage para exibí-la.

 

ShowMessage(GetURL);

 

Imagens do exemplo:

 

 

Figura1. Programa exemplo.

 

Figura2. URL copiada.