Page 1 of 1
Check "mouse clicked" event inside Chromium browser.
Posted: Fri Oct 27, 2023 6:49 am
by michal@dorfin.waw.pl
Is there any way to check if user clicked on the webpage in Chromium browser ?
I don't need the coordinates. I just need to know if user is active.
Is there any "event" on TChromium that I could handle ?
I know that I can check mouse events in Javascript and send message from renderer process to main process and execute my code in Delphi.
But I'd like to avoid injecting any JS code in the page.
Re: Check "mouse clicked" event inside Chromium browser.
Posted: Fri Oct 27, 2023 7:37 am
by salvadordf
Hi,
Use the TChromium.OnRenderCompMsg event and add this code to intercept the Windows message for mouse clicks :
Code: Select all
case aMessage.Msg of
WM_LBUTTONDOWN :
begin
// Your code.
end;
end;
Re: Check "mouse clicked" event inside Chromium browser.
Posted: Fri Oct 27, 2023 10:03 am
by michal@dorfin.waw.pl
As usual - quick and perfect answer. THANK YOU!
Re: Check "mouse clicked" event inside Chromium browser.
Posted: Fri Oct 27, 2023 1:25 pm
by salvadordf
Thanks to you for supporting this open source project in Patreon!

Re: Check "mouse clicked" event inside Chromium browser.
Posted: Thu Sep 12, 2024 5:00 pm
by Lis97
Good day, I have a similar task, I need to take into account the user's activity.
Therefore, there is no need to create a new topic and I am writing in a similar topic.
The task is simple, when you click the left mouse button in the browser, the OnClick() event should be called in the main form.
In the first version of the code, OnClick() works stably in the main form, but clicking the mouse in the browser does not work, it does not follow the links.
In the second case, OnClick() does not work in the main form, but it works fine, clicking the mouse in the browser works fine.
Please tell me what I am doing wrong.
Code: Select all
case aMessage.Msg of
WM_LBUTTONDOWN :
begin
aHandled := True;
PostMessage(Handle, WM_LBUTTONDOWN, 0, 0);
end;
end;
Code: Select all
case aMessage.Msg of
WM_LBUTTONDOWN :
begin
PostMessage(Handle, WM_LBUTTONDOWN, 0, 0);
end;
end;
Re: Check "mouse clicked" event inside Chromium browser.
Posted: Thu Sep 12, 2024 7:05 pm
by Lis97
I did it like this, it works

maybe it will be useful to someone
Code: Select all
case aMessage.Msg of
WM_LBUTTONDOWN :
begin
PostMessage(Handle, WM_LBUTTONDOWN, 0, 0);
PostMessage(Handle, WM_LBUTTONUP, 0, 0);
end;
end;