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.
ForestListener
Posts: 44 Joined: Sun Jul 07, 2019 1:46 pm
Post
by ForestListener » Wed Oct 02, 2019 12:11 pm
Hello!
Here is the code to simulate ctrl key press:
Code: Select all
TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN;
TempKeyEvent.modifiers := 0;
TempKeyEvent.windows_key_code := 17;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
Chromium1.SendKeyEvent(@TempKeyEvent);
// WM_CHAR
TempKeyEvent.kind := KEYEVENT_CHAR;
Chromium1.SendKeyEvent(@TempKeyEvent);
// WM_KEYUP
TempKeyEvent.kind := KEYEVENT_KEYUP;
Chromium1.SendKeyEvent(@TempKeyEvent);
Please, show the example, how to simulate ctrl+a?
Thank you!
salvadordf
Posts: 4565 Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:
Post
by salvadordf » Wed Oct 02, 2019 4:37 pm
You can simulate all the key presses but you need the right values for TempKeyEvent.
Open the
SimpleOSRBrowser demo, build it and log all the information about key presses that passes through the TForm1.AppEventsMessage procedure.
Read this message for more information :
https://www.briskbard.com/forum/viewtop ... 4231#p4231
ForestListener
Posts: 44 Joined: Sun Jul 07, 2019 1:46 pm
Post
by ForestListener » Thu Oct 03, 2019 5:13 am
Thank you, Salvador.
Excuse me, where is this demo, can you share the link?
salvadordf
Posts: 4565 Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:
Post
by salvadordf » Thu Oct 03, 2019 7:22 am
Download the latest CEF4Delphi version in the "master" branch from GitHub :
https://github.com/salvadordf/CEF4Delphi
Decompress it and open the "
demos " directory. Then open the "
Delphi_VCL " directory or the "
Lazarus " directory depending on the IDE you use. The SimpleOSRBrowser demo is in those directories.
ForestListener
Posts: 44 Joined: Sun Jul 07, 2019 1:46 pm
Post
by ForestListener » Thu Oct 03, 2019 9:44 am
Thanks a lot.
It works, but there is the problem
Code: Select all
// WM_KEYDOWN
TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN;
TempKeyEvent.modifiers := EVENTFLAG_CONTROL_DOWN;
TempKeyEvent.windows_key_code := 65;
TempKeyEvent.native_key_code := #0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
Chromium1.SendKeyEvent(@TempKeyEvent);
// WM_CHAR
TempKeyEvent.kind := KEYEVENT_CHAR;
Chromium1.SendKeyEvent(@TempKeyEvent);
// WM_KEYUP
TempKeyEvent.kind := KEYEVENT_KEYUP;
Chromium1.SendKeyEvent(@TempKeyEvent);
I've put this EVENTFLAG_CONTROL_DOWN in to TempKeyEvent.modifiers to simulate ctrl+a key combination (select all). It works great when text field contains a letter. But when text field is empty, this code typing letter A instead of simulating ctrl+a.
Can you suggest the solution?