Delphi – Automatic shutdown when not in use within a period of time

See the answer in English> How do I check for PROGRAM idle time, as opposed to SYSTEM idle time? Three
We have a program that we are writing in Delphi XE. I have A question:

If the program is not used for the duration that we set as a parameter, it should automatically return to the input screen. So like Windows, there must be controls like mouse and keyboard. can you help me?

Thank you.

Call GetLastInputInfo regularly. This will return the tick count of the last input event. Then the difference between the tick count of the input event and the current tick count is compared with the timeout.

The disadvantage of this method is that you have to deal with it 49-day rollover issue with 32-bit Windows tick count. As an alternative, you can choose to install a system hook to monitor keyboard and mouse events. This will allow you to avoid the 49-day rollover issue, but it is much more complicated to implement.

See the answer in English> How do I check for PROGRAM idle time, as opposed to SYSTEM idle time? Three
We have a program that we are writing in Delphi XE. There is a problem:

If the program is not used for the duration that we set as a parameter, it should automatically return to the input screen. So like Windows, there must be controls like mouse and keyboard .can you help me?

Thank you.

Call GetLastInputInfo regularly. This will return the tick count of the last input event. Then Compare the difference between the tick count of the input event and the current tick count with the timeout.

The disadvantage of this method is that you have to deal with the 49-day rollover problem with 32-bit Windows tick count. As an alternative, you can choose to install system hooks to monitor keyboard and mouse events. This will allow you to avoid the 49-day rollover issue, but it is much more complicated to implement.

Leave a Comment

Your email address will not be published.