Zamiana tekstu w przeglądarce

0

:-) Czy jest mozliwosć, aby taki kawałek kodu

var
   H : HWND;
   Text : string;
begin
   H := WindowFromPoint(Mouse.CursorPos);   //Uchwyt okna
   Text := '[email protected]';   //Tekst który ma być wpisany do danego okna

   SendMessage(H,WM_SetText,0,LongInt(Text));

lub za pomocą tego:

//najpierw
FindWindow() //Pobierasz uchwyt okna rodzica
FindWindowEX();   //A następnie uchwyt okien Child aż dojdziesz do właściwego okna do którego wysyłasz już znany ci komunikat. 

można byłoby zmodyfikować i zastosować do np. uruchomionej strony www w przeglądarce ?? Chodzi mi o np. pola tekstowe a nie tytuł z przeglądarki

[angel] pozdro

0

w FAQ masz jak pobrac adres z przegladarki
sadze ze da sie ten proces odwrocic

0

chodzi ci o ten faq:

http://4programmers.net/view_faq.php?id=180

zamieniłem ten kod, co mi go dałeś. Odczytuje i zamienia nazwy ale elementów programu (dolny pasek, tytuł, adres). Lecz nie zmienia i nie odczytuje elementów typu pole tekstowe z html.

function SetText(WindowHandle: hwnd):string;
var
  txtLength : integer;
  buffer: string;
  text : string;
  begin
TxtLength := SendMessage(WindowFromPoint(Mouse.CursorPos), WM_GETTEXTLENGTH, 0, 0);
txtlength := txtlength + 1;
setlength(buffer, txtlength);
text := 'heroman';
sendmessage (WindowHandle,wm_gettext, txtlength, longint(@buffer[1]));
SendMessage(WindowFromPoint(Mouse.CursorPos),WM_SetText,0,LongInt(text));
result := buffer;
end;

function setURL: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 := setText(WindowFromPoint(Mouse.CursorPos));
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(setURL);
end;
0

Proponuje takie cos

Wyrwane z programu wiec moze tak od razu nie dzialac ale zasada na pewno jest dobra

 Function GetItem(Form,Element :String) :IHTMLElement;
 var WebDoc : IHTMLDocument2;
     pDispatch : IDISPATCH;
     FormCollection : IHTMLElementCollection;
     FormElement : IHTMLFormElement;
     FormItem : IHTMLElement;
 Begin
  //  Get the document contained in the WebBrowser
  OleCheck(Form1.wb.Document.QueryInterface(IID_IHTMLDocument2,WebDoc));
  //  Get all the forms in the document as there can be more than one
  FormCollection := WebDoc.Get_forms;
  //  Get a pointer to the first form in the collection of forms
  pDispatch := FormCollection.item(Form, 0);
  //  Make sure it supports the correct interface
  OleCheck(pDispatch.QueryInterface(IID_IHTMLFormElement, FormElement));
  //  Get a pointer the desired element of the form
  //  In this case it is as text box called 'address1'
  pDispatch := FormElement.item(Element, 0);
  //  Make sure it supports the required interface
  OleCheck(pDispatch.QueryInterface(IID_IHTMLElement, FormItem));
  //
  Result:=FormItem;
 end;

 Procedure SetCombo(Form,Element :String; Val :Integer);
 var SelectElement :IHTMLSelectElement;
 Begin
  //  Make sure its a input element, and it supports the required
  if GetItem(Form,Element).QueryInterface(IID_IHTMLSelectElement, SelectElement) = 0 then
    begin
     //  Final check to make sure its a text box and then set the valueof it
     SelectElement.selectedIndex:=Val;
    end;
 End;

 Procedure FillForm(Form,Element,Val :String);
 var InputElement : IHTMLInputElement;
 Begin
  //  Make sure its a input element, and it supports the required
  if GetItem(Form,Element).QueryInterface(IID_IHTMLInputElement, InputElement) = 0 then
    begin
     //  Final check to make sure its a text box and then set the valueof it
     InputElement.Set_value(Val);
    end;
 End;

 Procedure Submit(Form,Element :String);
 var WebDoc : IHTMLDocument2;
     pDispatch : IDISPATCH;
     FormCollection : IHTMLElementCollection;
     FormElement : IHTMLFormElement;
     FormItem : IHTMLElement;
     InputElement : IHTMLInputElement;
 Begin
  //  Get the document contained in the WebBrowser
  OleCheck(Form1.wb.Document.QueryInterface(IID_IHTMLDocument2,WebDoc));
  //  Get all the forms in the document as there can be more than one
  FormCollection := WebDoc.Get_forms;
  //  Get a pointer to the first form in the collection of forms
  pDispatch := FormCollection.item(Form, 0);
  //  Make sure it supports the correct interface
  OleCheck(pDispatch.QueryInterface(IID_IHTMLFormElement, FormElement));
  //  In this case it is as text box called 'address1'
  pDispatch := FormElement.item(Element, 0);
  //  Make sure it supports the required interface
  OleCheck(pDispatch.QueryInterface(IID_IHTMLElement, FormItem));
  //
  FormItem.click;
 End;

 Procedure WaitFor;
 Begin
  While Form1.wb.Busy do
   Begin
    Sleep(10);
    Application.ProcessMessages;
   End;
 End;
0
  1. Jak użyc w/w kodu ??

IHTMLElement --> Project --> Import Type Libray --> Microsoft HTML Object Libray --> Install

pozdro :-|

1 użytkowników online, w tym zalogowanych: 0, gości: 1