Последние записи
- Получение картинки с веб-камеры
- Скопировать определённый кусок image
- Сделать printscreen экрана и сохранить
- Написать программу, считывает с клавиатуры определенное колличество цифр, а на экран выводит сумму наибольшей цифры
- Создать системную, невидимую, только для чтения папку
- Какой яп и ide выбрать для кроссплатформенного программирования?
- Скачать html страницу в memo с помощью indy
- Как разорвать adsl соединение с интернетом?
- Как отключить/включить сетевое соединение?
- Передать состояние CheckBox
24th
Авг
Как в WebBrowser выбрать из списка и нажать на кнопку?
Posted by Chas under Пост-обзор
Posted by Chas under Пост-обзор
Нажатие на кнопку:
код:
procedure PSpisokClick;
var HtmlDocument : IHtmlDocument2;
i : integer;
HtmlCollection : IHtmlElementCollection;
HtmlElement : IHtmlElement;
spisok : string;
begin
HtmlDocument := BrowserMain.Document as IHtmlDocument2;
HtmlCollection := HtmlDocument.All;
for i := 0 to HtmlCollection.length – 1 do
begin
if stop = 1 then Exit;
HtmlElement := HtmlCollection.Item(i, 1) as IHtmlElement;
spisok := HtmlElement.InnerText;
Trim(spisok);
if spisok = ‘список’ then
begin
HtmlElement.click;
Exit;
end;
end;
end;
var HtmlDocument : IHtmlDocument2;
i : integer;
HtmlCollection : IHtmlElementCollection;
HtmlElement : IHtmlElement;
spisok : string;
begin
HtmlDocument := BrowserMain.Document as IHtmlDocument2;
HtmlCollection := HtmlDocument.All;
for i := 0 to HtmlCollection.length – 1 do
begin
if stop = 1 then Exit;
HtmlElement := HtmlCollection.Item(i, 1) as IHtmlElement;
spisok := HtmlElement.InnerText;
Trim(spisok);
if spisok = ‘список’ then
begin
HtmlElement.click;
Exit;
end;
end;
end;
выбор из открывающегося списка:
код:
procedure SetFieldValue(theForm: IHTMLFormElement;
const fieldName, newValue: string; const instance: integer);
var
field: IHTMLElement;
inputField: IHTMLInputElement;
selectField: IHTMLSelectElement;
textField: IHTMLTextAreaElement;
begin
field := theForm.Item(fieldName,instance) as IHTMLElement;
if Assigned(field) then
begin
if field.tagName = ‘INPUT’ then
begin
inputField := field as IHTMLInputElement;
if (inputField.type_ ‘radio’) and (inputField.type_ ‘checkbox’)
then inputField.value := newValue
else inputField.checked := (newValue = ‘checked’);
end
else if field.tagName = ‘SELECT’ then
begin
selectField := field as IHTMLSelectElement;
selectField.value := newValue;
end
else if field.tagName = ‘TEXTAREA’ then
begin
textField := field as IHTMLTextAreaElement;
textField.value := newValue;
end;
end;
end;
const fieldName, newValue: string; const instance: integer);
var
field: IHTMLElement;
inputField: IHTMLInputElement;
selectField: IHTMLSelectElement;
textField: IHTMLTextAreaElement;
begin
field := theForm.Item(fieldName,instance) as IHTMLElement;
if Assigned(field) then
begin
if field.tagName = ‘INPUT’ then
begin
inputField := field as IHTMLInputElement;
if (inputField.type_ ‘radio’) and (inputField.type_ ‘checkbox’)
then inputField.value := newValue
else inputField.checked := (newValue = ‘checked’);
end
else if field.tagName = ‘SELECT’ then
begin
selectField := field as IHTMLSelectElement;
selectField.value := newValue;
end
else if field.tagName = ‘TEXTAREA’ then
begin
textField := field as IHTMLTextAreaElement;
textField.value := newValue;
end;
end;
end;
вызов процедуры:
код:
theForm := GetFormByNumber(BrowserMain.Documen t as IHTMLDocument2,0);
SetFieldValue(theForm,’type’,переменная);
SetFieldValue(theForm,’type’,переменная);

