What I want to achieve is that when the Mac boots, my session starts without me needing to type my user and password.
I have created a daemon that launches at boot time and this daemon will call the script that will contain the commands I'm asking for (providing by default my user and password I assume).
I can't configure my session to start automatically in System Preferences because if my script fails by any reason, then I need the login screen to ask for my credentials.
Is this even possible to achieve?
Best Answer
I found a solution to what I wanted so I'll post it just in case anyone is looking for something similar:
At boot time I launch a daemon that executes the following script:
In the login screen the script selects the first user account with the up arrow (key code 126), then an enter (keystroke return) brings the textfield to input the password and finally another enter to login.
IF there's an error during the execution of the script, then you still have the login screen to authenticate the user.