Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Autocomplete document
Autocomplete document
Hello, I'm looking for another alternative to the native Delphi TWebBrowser, and I've found this solution, but I've seen that it's not as simple to work with as the TwebBrowser, what I need is that after the page loads, fill out the form that is in it, and click the submit button.
could you give me an example of how to do this? I looked at the demo DOMVisitor but could not do anything like it.
thanks!
could you give me an example of how to do this? I looked at the demo DOMVisitor but could not do anything like it.
thanks!
Re: Autocomplete document
Thanks, I'm using javascript, very good component! : D
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Autocomplete document
Is there any example about how to use TChromium.Browser.Host.SendKeyEvent ?Winexcel wrote: Thu Feb 15, 2018 4:57 pm Hi, there are three ways.
1. Using the chromium events like these:
TChromium.Browser.Host.SendMouseClickEvent
TChromium.Browser.Host.SendKeyEvent
for these purposes.
2. Use your own javascript which will fill out all your fields and click a submit button. You can execute javascript with function TChromium.Browser.Mainframe.ExecuteJavascript
3. The way which means that you will use combination of above methods
Show your code what you tried to do.
Re: Autocomplete document
I also need an example, since the form I'm working on, if I simply enter the value via javascript field.value = '123456' it from the error by clicking the submit button, stating that the field needs to have 6 characters, ie the validation is typing, I need to simulate an event in the field, something likeWinexcel wrote: Thu Feb 15, 2018 4:57 pm Hi, there are three ways.
1. Using the chromium events like these:
TChromium.Browser.Host.SendMouseClickEvent
TChromium.Browser.Host.SendKeyEvent
for these purposes.
2. Use your own javascript which will fill out all your fields and click a submit button. You can execute javascript with function TChromium.Browser.Mainframe.ExecuteJavascript
3. The way which means that you will use combination of above methods
Show your code what you tried to do.
SendKeys ('123456');
thanks!
Re: Autocomplete document
One question now, how do I get the "native_key_code" of a character? to get the "windows_key_code" I do so windows_key_code: = ord ('a');Winexcel wrote: Tue Feb 20, 2018 11:31 pm Build the SimpleOSRBrowser demo and log all the information sent to the browser when the TForm1.AppEventsMessage procedure receives a keyboard messages.
Copy that code in your application.
Code: Select all
procedure SendKeysWB(keys : String);
var
TempKeyEvent : TCefKeyEvent;
I, wPar, lPar : Integer;
c : char;
begin
keys := RemoveCharsString(keys);
try
for I := 1 to Length(keys) do
begin
c := keys[I];
wPar := ord(c);
lPar := 0000000; //????
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(wPar, lPar);
TempKeyEvent.windows_key_code := wPar;
TempKeyEvent.native_key_code := lPar;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
WebBC.SendKeyEvent(@TempKeyEvent);
end;
Except
on e: exception do
begin
FPrin.AddMsgMemo(MLogsGeral, 'Erro:' + e.Message);
end;
end;
end;
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Autocomplete document
Set native_key_code to 0.
Remember to include all the code that the SimpleOSRBrowser demo has for the WM_KEYDOWN, WM_CHAR and WM_KEYUP messages.
Remember to include all the code that the SimpleOSRBrowser demo has for the WM_KEYDOWN, WM_CHAR and WM_KEYUP messages.
-
- Posts: 513
- Joined: Thu Aug 10, 2017 12:40 pm
Re: Autocomplete document
Hello,
I'm getting error on this line :
[DCC Error] form1.pas(3748): E2003 Undeclared identifier: 'RemoveCharsString'
Any hints ?
Thanks !
I'm getting error on this line :
[DCC Error] form1.pas(3748): E2003 Undeclared identifier: 'RemoveCharsString'
Any hints ?
Thanks !
- salvadordf
- Posts: 4564
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Autocomplete document
I can't find "RemoveCharsString" in any CEF4Delphi file. 
