| View previous topic :: View next topic |
| Author |
Message |
live4eva5 Cheater
Reputation: 0
Joined: 01 Jul 2007 Posts: 38
|
Posted: Tue Oct 27, 2009 4:39 pm Post subject: [DELPHI REQUEST] Input to forms |
|
|
I am having proplems
In delphi i want to code so you put in a word in a text feild then next to it there will be the webbrowser component and i want it to input the word into the text feild then automatically submit it. |
|
| Back to top |
|
 |
Mabje Newbie cheater
Reputation: 0
Joined: 25 Dec 2007 Posts: 16 Location: Norway
|
Posted: Sun Nov 01, 2009 6:13 am Post subject: |
|
|
You could use this piece of code. It should work.
| Code: | function FillForm(WebBrowser: TWebBrowser; FieldName: string; Value: string): Boolean;
var
i, j: Integer;
FormItem: Variant;
begin
Result := False;
//no form on document
if WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 then
begin
Exit;
end;
//count forms on document
for I := 0 to WebBrowser.OleObject.Document.forms.Length - 1 do
begin
FormItem := WebBrowser.OleObject.Document.forms.Item(I);
for j := 0 to FormItem.Length - 1 do
begin
try
//when the fieldname is found, try to fill out
if FormItem.Item(j).Name = FieldName then
begin
FormItem.Item(j).Value := Value;
Result := True;
end;
except
Exit;
end;
end;
end;
end;
|
Example: | Code: |
begin
if FillForm(Webbrowser1, 'username', 'ExampleName') = False then
ShowMessage('Error. Field not available or no Form found.');
end;
|
Hope this helped you out a bit. |
|
| Back to top |
|
 |
live4eva5 Cheater
Reputation: 0
Joined: 01 Jul 2007 Posts: 38
|
Posted: Tue Nov 03, 2009 12:57 pm Post subject: |
|
|
Thanks mate its better then the code i was useing thanks alot mate =]
how do you make it press buttons tho ? |
|
| Back to top |
|
 |
Mabje Newbie cheater
Reputation: 0
Joined: 25 Dec 2007 Posts: 16 Location: Norway
|
Posted: Wed Nov 04, 2009 5:37 pm Post subject: |
|
|
I am glad it helped you out a bit If there is only one submit button, i just use this:
Browser.OleObject.document.forms.item(0).submit();
But if there is several submit buttons, then you have to do a bit more work.. Out of curiosity, what are you making?  |
|
| Back to top |
|
 |
live4eva5 Cheater
Reputation: 0
Joined: 01 Jul 2007 Posts: 38
|
Posted: Thu Nov 05, 2009 5:24 am Post subject: |
|
|
Im just messing around im working out new ways to make like a quick status in twitter i seen that and im working on different ways to make it work so i can learn more in delphi because im supposed to be doing it in college >.<
thanks man it worked =] |
|
| Back to top |
|
 |
Mabje Newbie cheater
Reputation: 0
Joined: 25 Dec 2007 Posts: 16 Location: Norway
|
Posted: Thu Nov 05, 2009 5:26 pm Post subject: |
|
|
Aah! I see Its good to be well prepared for college, and messing around like this helps alot
No problem, I hope you take the time to try to understand a bit of the code  |
|
| Back to top |
|
 |
live4eva5 Cheater
Reputation: 0
Joined: 01 Jul 2007 Posts: 38
|
Posted: Fri Nov 06, 2009 11:18 am Post subject: |
|
|
Haha we start codeing in a couple of weeks so >.<
And yes ive taken time i need to know the code anyway so
thanks alot  |
|
| Back to top |
|
 |
|