:-) hmm Inter nie chodzi mi o czaty, ale ogólnie elementy typu np. pole tekstowe, przycisk, listy.
Najpierw znalazłem kod i go przemieniłem:
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;
Okazuje się, że odczytuje daną tresć i zmienia go na słowo "heroman", np,. zmienia w przeglądarce pasek narzędzi, stanu, adres, wszystko lecz nie strone.
Może trzeba zmienić ten kod:
- dla kodu potrzebny jest komponent IHTMLElement --> Project --> Import Type Libray --> Microsoft HTML Object Libray --> Install
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;
Ma ktoś jakiś pomysł [???]