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.

Linux Console Application

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

Re: Linux Console Application

Post by salvadordf »

Read these documents :
https://www.chromium.org/developers/design-documents/multi-process-architecture/
https://www.briskbard.com/index.php?lang=en&pageid=cef

Chromium uses several processes to implement the web browser and the IDE can only debug one process at a time.
Setting SingleProcess to True forces Chromium to use only one process and that's why the event seems to work then.
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

Thank you. <3
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

Another question with Linux Console Application.

I am trying to click on an input text and type something on it and submit.

I am getting coordinates of center of input, I am clicking but I can't type inside it. I tested with

Code: Select all

<input type="text" name="testinput" class="testinput"><button class="testbutton" onclick="var value = document.querySelector('.testinput').value; if(value.trim() === '') { console.log('Empty'); } else { console.log(value); }">Submit button</button>
<script>

    window.onload = function() {
        document.querySelector('.testinput').focus();
    };
	
    document.addEventListener('click', function(event) {
        const x = event.clientX;
        const y = event.clientY;
        console.log(`Clicked at (${x}, ${y})`);
    });

    document.addEventListener('keyup', function(event) {
        console.log(event.key);
    });
</script>
I can see it, it types on chromium but not in input.

it returns Empty all the time. Can you help me please?
User avatar
salvadordf
Posts: 4059
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Linux Console Application

Post by salvadordf »

The ConsoleBrowser demo for Linux uses the off-screen rendering mode, also known as OSR mode.

In this mode the application detects all mouse and keyboard events, form visibility, focus, etc. and then it simulates all those events in the browser.

See the CEF4Delphi/demos/Lazarus_Linux_GTK3/OSRExternalPumpBrowser demo which also uses the OSR mode and copy the code that simulates all the keyboard, mouse and focus events.
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

I have implemented the same. I give the input coordinates, it clicks on it, then types, js result shows that it types, and then it clicks to button, button returns that input is empty.

I can click on input, I have checked with javascript.
I can send key presses, I have checked with javascript too,
but I can't type in input. :/

What am i missing? Can you lead me? :cry:

Btw I tested same with Lazarus_Linux_GTK3/OSRExternalPumpBrowser everything works as expected. But it's not working with Console Application.

Any help would be appreciated.
User avatar
salvadordf
Posts: 4059
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Linux Console Application

Post by salvadordf »

Maybe it needs to call FBrowser.WasHidden(False) and FBrowser.SetFocus(True) after the browser initialization :
https://github.com/salvadordf/CEF4Delphi/blob/7d822c534016c9ac9b3f7ade9d2601bae9cbb96a/demos/Lazarus_Linux_GTK3/OSRExternalPumpBrowser/uosrexternalpumpbrowser.pas#L691
alfredapple
Posts: 9
Joined: Tue Mar 12, 2024 1:21 pm

Re: Linux Console Application

Post by alfredapple »

No luck.

That's not it.

I can't make it click on an input and type inside in Linux Console Application, same code works with OSRExternalPumpBrowser.

I feel like, I am missing something about focus. :/
User avatar
salvadordf
Posts: 4059
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Linux Console Application

Post by salvadordf »

The ConsoleBrowser demo is a stripped-down version of a OSR demo. It only has the necessary code to take a screenshot and everything else was removed.

Use the OSRExternalPumpBrowser demo to log all mouse and keyboard events.

Add all the missing code to ConsoleBrowser from OSRExternalPumpBrowser and then try to replay all those recorded events and it should have the same results.
Post Reply