This tech note presents a simple way of automatically quitting a client that isn’t in use.
The code presented here relies on the ON EVENT CALL command, with which we can detect mouse clicks and key presses. We also use a process that runs regularly to check whether the ON EVENT CALL method has been called recently. If there has been no key press or mouse click since the process last ran, the process quits the client.
We employ a Boolean variable to mean ‘A key press or mouse click has not recently occurred’. The startup method and the ON EVENT CALL method set this variable to False. The process which runs regularly sets this variable to True if it wasn’t already True. If it was true, it must have been true since the process last ran, so there hasn’t been any user activity in this time and the process then quits the client.
This tech note presents a simple way of automatically quitting a client that isn’t in use.
The code presented here relies on the ON EVENT CALL command, with which we can detect mouse clicks and key presses. We also use a process that runs regularly to check whether the ON EVENT CALL method has been called recently. If there has been no key press or mouse click since the process last ran, the process quits the client.
We employ a Boolean variable to mean ‘A key press or mouse click has not recently occurred’. The startup method and the ON EVENT CALL method set this variable to False. The process which runs regularly sets this variable to True if it wasn’t already True. If it was true, it must have been true since the process last ran, so there hasn’t been any user activity in this time and the process then quits the client.
Tech Note