Detect idle timeoutΒΆ
Introduction
In Q Applications with interactive graphic (see Interactive session and Presentation engine), application logics linked to user inactivity, e.g. absence of cursor movements, keyboard actions or interface interactions, can be created. Typically, a screen saver or a user session automatic logout is configured. This can be done using a Q Studio default script.
NetLogic Idle Timeout
In the library, the NetLogic (see NetLogic) Idle Timeout is available, which makes it possible to invoke a method after a set idle timeout. These are its properties:
Properties |
Description |
---|---|
Enabled |
Enable the script. |
Duration |
Duration of the idle timeout after which the method is invoked. |
OnTimeout |
Method to run. Once selected, any arguments can be configured. |
Use the NetLogic Idle Timeout
Click to open the template library, then in Scripts select Idle Timeout and drag it inside the window to be used as the start window (e.g. MainWindow (type)).
Important
since Idle Timeout acts on the user interface at runtime, it must be inside the startup window, preferably directly inside it.
To enable the NetLogic, set the Enabled property to True.
In Duration, set the desired idle timeout.
Click next to OnTimeout to select the method to invoke at the end of the idle timeout.
Example: request authentication from the user after an idle timeout
The NetLogic Idle Timeout can be used to design the request of new login for the same user after an idle timeout.
In this example, the screen shown after the idle timeout consists of the following objects:
An initially hidden Rectangle object (Visibility property = False, with black fill, which adjusts to the size of the main window (MainWindow (type)). In turn, it contains the objects listed below.
A text box to use as the dialog box with the enter password request.
A text box for the password box.
A button to confirm the password.
A button for the logout.
Note
this example focuses on the logic related to displaying the screen, while ignoring the logic related to the user password check and logout.
To display the login screen after an idle timeout, Idle Timeout must display the initially hidden rectangle and its contents overlaying the graphical objects displayed at runtime. To do this, a method must be invoked to change the value of the Rectangle object Visibility property from False to True. Below is a configuration example:
Click to open the template library, then in Scripts select Idle Timeout and drag it onto MainWindow (type) in Project.
Set the Enabled property to True.
In Duration, set the idle timeout.
Click next to OnTimeout to select the method to invoke at the end of the idle timeout, in this case the global method Commands > Commands for variables > Invert value, which inverts the value of a Boolean variable.
In the OnTimeout method arguments, click next to VariableToModify to select the Visibility property of the Rectangle object.