Prevent Windows screen lock when playing with joystick
Solution 1:
Whenever you press a key on the keyboard, or move/click the mouse, Windows resets its idle timer. There is a Windows API function you can call that resets the idle timer in exactly the same way. By calling the function at regular intervals, the screen-saver will never activate and the computer will never lock. This is what VLC and other applications do.
The function name is SetThreadExecutionState
and is found in kernel32.dll
. In VB the actual call looks like this:
SetThreadExecutionState(ES_SYSTEM_REQUIRED Or ES_DISPLAY_REQUIRED)
The two constants being:
ES_SYSTEM_REQUIRED = &H1
and ES_DISPLAY_REQUIRED = &H2
You can't make these calls from VBScript, so you'd need something more advanced to code this up with.
Incidentally, the above is the technically correct way of doing this. Many utilities I've seen on the web use silly tricks like simulating keystrokes or jiggling the mouse. That's bad in my opinion, as it can interfere with your work.
Anyway, I've digressed too much. This kind of stuff belongs on Stack Overflow.