Page 1 of 1

Autocomplete document

Posted: Thu Feb 15, 2018 4:36 pm
by darkducke
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!

Re: Autocomplete document

Posted: Thu Feb 15, 2018 7:20 pm
by darkducke
Thanks, I'm using javascript, very good component! : D

Re: Autocomplete document

Posted: Sun Feb 18, 2018 5:39 pm
by thefunkyjoint
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.
Is there any example about how to use TChromium.Browser.Host.SendKeyEvent ?

Re: Autocomplete document

Posted: Tue Feb 20, 2018 7:57 pm
by darkducke
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.
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 like
SendKeys ('123456');

thanks!

Re: Autocomplete document

Posted: Wed Feb 21, 2018 2:44 pm
by darkducke
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.
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');

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;

Re: Autocomplete document

Posted: Wed Feb 21, 2018 3:39 pm
by salvadordf
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.

Re: Autocomplete document

Posted: Wed Feb 28, 2018 5:38 pm
by thefunkyjoint
Hello,

I'm getting error on this line :

[DCC Error] form1.pas(3748): E2003 Undeclared identifier: 'RemoveCharsString'

Any hints ?

Thanks !

Re: Autocomplete document

Posted: Wed Feb 28, 2018 5:51 pm
by salvadordf
I can't find "RemoveCharsString" in any CEF4Delphi file. :?