Page 1 of 1
Simulating keypress without OSR mode
Posted: Tue Jul 16, 2019 7:50 am
by ForestListener
Hello!
Is it possible to simulate keypress? For example, arrow down without OSR mode (i cant use OSR mode by some reason).
I know how to set focus to element on WEBpage by Javascript (i did it).
Now i need to sumulate keypress (like i press keyboard key).
Thank you!
Re: Simulating keypress without OSR mode
Posted: Wed Jul 17, 2019 8:26 am
by ForestListener
Also i've got Access violation any time i modifying Event14: PCEFKeyEvent. Why?
Code: Select all
...
var
...
Event14: PCEFKeyEvent;
begin
FillChar(Event14, SizeOf(PCefKeyEvent), 0);
Event14.kind := KEYEVENT_KEYDOWN; // ACCESS VIOLATION HERE!
//Event14.character:='a'; // ACCESS VIOLATION HERE!
//Event14.windows_key_code:=ord('a'); // ACCESS VIOLATION HERE!
Chromium1.Browser.Host.SendKeyEvent(Event14);
Re: Simulating keypress without OSR mode
Posted: Thu Jul 18, 2019 10:13 am
by salvadordf
Hi,
Sorry for the delay.
Please, download the latest CEF4Delphi version from GitHub and run the MiniBrowser demo. It has a new menu option to simulate key presses in normal mode that you can copy and adapt to your application.
https://github.com/salvadordf/CEF4Delph ... r.pas#L851
Re: Simulating keypress without OSR mode
Posted: Thu Jul 18, 2019 11:59 am
by ForestListener
Thank you, Salvador!
Re: Simulating keypress without OSR mode
Posted: Thu Jul 18, 2019 12:16 pm
by ForestListener
It is perfectly works!
Re: Simulating keypress without OSR mode
Posted: Mon Sep 23, 2019 6:55 am
by gresaggr
Hello.
I can't send characters like this: "!@#$%^&* "with this code.
Could you help me with this problem?
Re: Simulating keypress without OSR mode
Posted: Mon Sep 23, 2019 7:38 am
by salvadordf
Hi,
The code in the MiniBrowser demo only simulates WM_KEYDOWN, WM_CHAR and WM_KEYUP messages by calling TChromium.SendKeyEvent with a TCefKeyEvent parameter but some keys might need to simulate additional windows messages with different values for the TCefKeyEvent parameter.
All that information can be obtained with the SimpleOSRBrowser demo. Build it and log all the keyboard related messages that pass through the TForm1.AppEventsMessage procedure when you press those keys.
Re: Simulating keypress without OSR mode
Posted: Mon Sep 23, 2019 9:15 am
by gresaggr
salvadordf wrote: Mon Sep 23, 2019 7:38 am
All that information can be obtained with the
SimpleOSRBrowser demo.
Thank you! It's work!