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.
Simulating keypress without OSR mode
-
- Posts: 44
- Joined: Sun Jul 07, 2019 1:46 pm
Simulating keypress without OSR mode
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!
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!
-
- Posts: 44
- Joined: Sun Jul 07, 2019 1:46 pm
Re: Simulating keypress without OSR mode
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);
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Simulating keypress without OSR mode
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
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
-
- Posts: 44
- Joined: Sun Jul 07, 2019 1:46 pm
Re: Simulating keypress without OSR mode
Thank you, Salvador!
-
- Posts: 44
- Joined: Sun Jul 07, 2019 1:46 pm
Re: Simulating keypress without OSR mode
It is perfectly works!
Re: Simulating keypress without OSR mode
Hello.
I can't send characters like this: "!@#$%^&* "with this code.
Could you help me with this problem?
I can't send characters like this: "!@#$%^&* "with this code.
Could you help me with this problem?
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Simulating keypress without OSR mode
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.
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
Thank you! It's work!salvadordf wrote: Mon Sep 23, 2019 7:38 am All that information can be obtained with the SimpleOSRBrowser demo.