Page 2 of 2

Re: Linux Console Application

Posted: Mon Apr 15, 2024 9:02 pm
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.

Re: Linux Console Application

Posted: Mon Apr 15, 2024 9:05 pm
by alfredapple
Thank you. <3

Re: Linux Console Application

Posted: Fri Apr 19, 2024 3:00 am
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?

Re: Linux Console Application

Posted: Fri Apr 19, 2024 8:15 am
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.

Re: Linux Console Application

Posted: Fri Apr 19, 2024 11:17 pm
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.

Re: Linux Console Application

Posted: Sat Apr 20, 2024 2:17 pm
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

Re: Linux Console Application

Posted: Sat Apr 20, 2024 4:33 pm
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. :/

Re: Linux Console Application

Posted: Sun Apr 21, 2024 2:15 pm
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.