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.

Problems with ExecuteJavaScript delphi

Post Reply
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems with ExecuteJavaScript delphi

Post by salvadordf »

Hi,

Perhaps that web page has some kind of protection against JavaScript modifications in the client.

Read this :
https://stackoverflow.com/questions/318 ... lient-side
https://stackoverflow.com/questions/205 ... er-console
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems with ExecuteJavaScript delphi

Post by salvadordf »

Wagner12345 wrote: Mon Dec 03, 2018 2:08 am Is there a possibility that I can simulate the keystrokes of the keyboard in the same way that was used to simulate a click on the Dom?

procedure Simulate_Mouse_Click(X : string; Y : string);
var
MouseEvent : TCefMouseEvent;
KeyEvent : TCefKeyEvent;
begin
MouseEvent.x := strtoint(X)+5;
MouseEvent.y := strtoint(Y)+5;
MiniBrowserFrm.Chromium1.Browser.Host.SendFocusEvent(true);
MiniBrowserFrm.Chromium1.Browser.Host.SendMouseClickEvent(PCefMouseEvent(@MouseEvent), MBT_LEFT, false, 1);
MiniBrowserFrm.Chromium1.Browser.Host.SendMouseClickEvent(PCefMouseEvent(@MouseEvent), MBT_LEFT, true, 1);

end;
You can try the solution given by qaplok or you can use a browser in OSR mode to log every mouse and keyboard event and later you can send the logged data.

Read this :
https://www.briskbard.com/forum/viewtop ... =112&p=372
donald7771
Posts: 7
Joined: Thu Jul 26, 2018 5:14 pm

Re: Problems with ExecuteJavaScript delphi

Post by donald7771 »

Is there a possibility that I can simulate the keystrokes of the keyboard in the same way that was used to simulate a click on the Dom?
Take a look at my post:
https://www.briskbard.com/forum/viewtopic.php?f=8&t=620
I showed a trick to simulate a click without javascript!
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems with ExecuteJavaScript delphi

Post by salvadordf »

The "SimpleOSRBrowser" demo has examples for the SendKeyEvent, SendMouseClickEvent, SendMouseMoveEvent and SendMouseWheelEvent procedures but that's a browser in OSR mode.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problems with ExecuteJavaScript delphi

Post by salvadordf »

A few things are done differently in CEF4Delphi but the demos have code examples about many of the most frequently used features.

Open the "DOMVisitor" demo and read the code comments in uDOMVisitor.pas

That demo creates DOM visitors in the GlobalCEFApp_OnProcessMessageReceived procedure and it sends the results using process messages.

Copy all he CEF4Delphi units in the "uses" sections to your application's "uses" sections. You need uCEFProcessMessage to create a TCefProcessMessageRef instance.
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Problems with ExecuteJavaScript delphi

Post by dilfich »

Code: Select all

Chromium1.SendMouseClickEvent(@MouseEvent, MBT_LEFT
Why the script does not specify a button number?
evt.buttons equal to 0 and not 1
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Problems with ExecuteJavaScript delphi

Post by dilfich »

dilfich wrote: Wed Sep 25, 2019 8:30 am

Code: Select all

Chromium1.SendMouseClickEvent(@MouseEvent, MBT_LEFT
Why the script does not specify a button number?
evt.buttons equal to 0 and not 1
MouseEvent.modifiers := GetCefMouseModifiers(1); :roll:
Post Reply