https://adrenalinebot.com/en/api/adrenaline/Classes/TL2Control#AuthLogin for enter login/passw
if server have protection most likely winapi keyclicks doesnt work, then you can try use "Engine.UseKey" https://adrenalinebot.com/en/api/adrenaline/Classes/TL2Control#UseKey
for disconnect, well if u get disconnect while u trying log in, then at very end of login , u can do check for if u are online, if not close client, and login again.
if u get disconnect while playing, and bot not shows that u are diconnected, u can try do thread procedure, which would check if u moved/get some specific items in last 60sec or so, if not do any of those, most likely u diconnected and u can close client for login again.
however i dont have any examples of that, but u can try adapt this code https://adrenalinebot.com/en/api/example/checking-if-our-character-is-stuck-in-the-thread for client close if u not moved.