# Login The login screen is the first screen you see when you open a client and it finishes loading: ```{figure} ../../images/loginscreen.png ``` WaspLib's {ref}`TLogin` can handle both resizable and fixed mode login screens. - - - (LOGIN_MESSAGES)= ## Login Messages ```pascal const LOGIN_MESSAGES = [ 'Welcome to ', 'Connecting to server', ..., 'Authenticator' ]; ``` Constant of all the login messages the login screen can handle. - - - ## Login Enums ```pascal ELoginMode = enum(UNKNOWN, LEGACY, LAUNCHER); ELoginButton = enum(LAUNCHER, EXISTING_USER, LOGIN, RETRY, OKAY, CONTINUE); ELoginInput = enum(USERNAME, PASSWORD); ELoginMessage = enum(UNKNOWN, WELCOME, ..., AUTHENTICATOR); ``` Enums representing various aspects of the login screen. `ELoginMessage` is a enum representation of {ref}`LOGIN_MESSAGES`. - - - ## TLogin Main record responsible for handling the {ref}`Login` screen. ```{figure} ../../images/Tlogin.png The login screen. ``` - - - ## Login.Setup ```pascal procedure TLogin.Setup(); ``` Internal method responsible for setting up the {ref}`TLogin` coordinates. This is automatically called for you on the {ref}`Login variable`. - - - ## Login.FindButton ```pascal function TLogin.FindButton(button: ELoginButton): Boolean; ``` Attempts to find the specified `ELoginButton`, returns `True` if we find it. - - - ## Login.ClickButton ```pascal function TLogin.ClickButton(button: ELoginButton): Boolean; ``` Attempts to click the specified `ELoginButton`, returns `True` if we succeed. Example: ```pascal WriteLn Login.ClickButton(ELoginButton.LOGIN); ``` - - - ## Login.SelectInput ```pascal function TLogin.SelectInput(field: ELoginInput): Boolean; ``` Attempts to select the specified `ELoginInput`, returns `True` if we succeed. This waits a few milliseconds for the flashing yellow cursor for confirmation. Example: ```pascal WriteLn Login.SelectInput(ELoginInput.USERNAME); ``` - - - ## Login.InputIsFilled ```pascal function TLogin.InputIsFilled(field: ELoginInput): Boolean; ``` Returns True/False if the specified `field` is filled. Example: ```pascal WriteLn Login.InputIsFilled(ELoginInput.USERNAME); ``` - - - ## Login.ClearInput ```pascal function TLogin.ClearInput(field: ELoginInput): Boolean; ``` Attempts to clear the specified `field`. Example: ```pascal WriteLn Login.ClearInput(ELoginInput.USERNAME); ``` - - - ## Login.FillInput ```pascal function TLogin.FillInput(field: ELoginInput; details: String): Boolean; ``` Attempts to fill the specified `field` with `details`. Example: ```pascal WriteLn Login.FillInput(ELoginInput.USERNAME, 'myprofile@email.com'); ``` - - - ## Login.GetMessage ```pascal function TLogin.GetMessage(): ELoginMessage; ``` Returns the currently visible login message as a `ELoginMessage`. Check {ref}`Login Enums` for more information on `ELoginMessage`. Example: ```pascal WriteLn Login.GetMessage(); ``` - - - ## Login.GetMode ```pascal function TLogin.GetMode(): ELoginMode; ``` Returns the current login mode as a `ELoginMode`. The login mode can only be known from the "Welcome to " screen. Check {ref}`Login Enums` for more information on `ELoginMode`. Example: ```pascal WriteLn Login.GetMode(); ``` - - - ## Login.HandleWelcome ```pascal function TLogin.HandleWelcome(): Boolean; ``` Attempts to handle the "Welcome to " screen regardless of the `ELoginMode` the client is on. Check {ref}`Login Enums` for more information on `ELoginMode`. Example: ```pascal WriteLn Login.HandleWelcome(); ``` - - - ## Login.Back2Welcome ```pascal function TLogin.Back2Welcome(): Boolean; ``` Attempts to return to the "Welcome to " screen. This is used to handle any screen that has an "Ok" button. Returns True if we succeed. Example: ```pascal WriteLn Login.Back2Welcome(); ``` - - - ## Login.EnterCredentials ```pascal function TLogin.EnterCredentials(username, password: String): Boolean; ``` Attempts to enter a user credentials. Example: ```pascal WriteLn Login.EnterCredentials('username', 'password'); ``` - - - ## Login.Retry ```pascal function TLogin.Retry(msg: ELoginMessage): Boolean; ``` Attempts to handle any screen that has a "Retry" button. Returns True if we succeed. The current `ELoginMessage` message has to be passed as `msg` so we know when we successfully handled the button. - - - ## Login.HandleError ```pascal function TLogin.HandleError(msg: ELoginMessage): Boolean; ``` Attempts to handle any screen that has an error message. Returns True if we succeed. The current `ELoginMessage` message has to be passed as `msg` so we know when we successfully handled the current error. Everytime this function is called, the internal `Login.Attempts` variable is increased. After 10 times of this being called without `Login.Attempts` being reset, this will raise an exception **IF** the reason we can't login is not the world being full. **IF** the reason is the world being full, this can be called forever. - - - ## Login.HandleMessage ```pascal function TLogin.HandleMessage(msg: ELoginMessage; username, password: String): Boolean; ``` Attempts to handle whatever screen the login screen is currently at. Returns True if we succeed. The current `ELoginMessage` message has to be passed as `msg` so we know when we successfully handled the current error. The profile `username` and `password` we want to use also have to be passed in. This can be empty value if we are using the Jagex Launcher, e.g.: `'', ''`. On certain `ELoginMessages` that cannot be handled this will raise an exception to shutdown your script. For example, if the profile you are trying to use has been banned. - - - ## Login.SwitchWorld ```pascal procedure TLogin.SwitchWorld(worlds: TIntegerArray); ``` Ensures we are on a world declared in the profile, retrying transient failures before giving up. - - - ## Login.DoLogin ```pascal function TLogin.DoLogin(profile: TProfile): Boolean; ``` Attempts to login into `profile`. If we login, the {ref}`Lobby` screen is handled for you. Returns true if we succeed. Example: ```pascal WriteLn Login.DoLogin(profile); ``` - - - ## Login variable Global {ref}`TLogin` variable.