I suspect key to what I think you want is in the function that is told to open a project after its chosen in the Example Window -
ide/main.pp:813: function DoOpenProjectFile(AFileName: string;
You should add a parameter to that that tells it that after it has opened the project, it should compile and run it.
No need for a new parameter. The IDE interface already has functions DoRunProject and DoRunProjectWithoutDebug.
There can be an option for ExampleWindow to run a project right after opening it.
In most cases, the value to the end user of the Examples is the chance to look at the code. yep, they might compile and run to ensure its the example they think it is but browsing across the code is the benefit.
Yes, the request sounds unusual. Usually people want to look at an example project's forms and/or code for a while before running it. Also, pressing F9 is a rather small task.
Still, if somebody wants such an option, it makes no harm to others.
I opened the Example Projects window after a long pause.
The list is empty.

The option "
Directory where Examples go" is :
/home/juha/.lazarus/examples_work_dir/which is correct.
That directory is empty but the projects under Lazarus source examples/ directory should be shown.
I have the latest Git main branch on a Manjaro Linux and start Lazarus as "
./lazarus &" from the source dir which is
~/SW/lazarus.
I remember having the same problem in the early tests a long time ago. I don't remember how it was solved. Maybe I had to change the code somehow.
[Edit] Oops, actually it works with a clean Lazarus configuration, like "
./lazarus --pcp=~/.lazarus_test &".
The default config is old and must be corrupt somehow.
I must delete it and tweak the settings again. I will lose file and project history and some settings but it is OK.
[Edit2] No, the example list becomes empty right after opening any project, eg. lazarus.lpi or one of the examples.
To reproduce on a Linux system :
1. Start Lazarus with a clean configuration, either by --pcp= parameter or by deleting the default config directory (~/.lazarus).
2. Open the Tools -> Example Projects window. The list is filled.
3. Close the Example Projects window. Open ide/lazarus.lpi.
4. Open the Example Projects window again. The list is empty.
An alternative step 3.: Open one of the example projects from the window. It opens OK.
Then continue with step 4.
This is annoying. Project settings should not affect the Example Projects window anyhow.
How is it possible that nobody has noticed this?