Prevent windows screen lock when playing with joystick
My windows 7 system is set to lock the screen after 20 mins of inactivity. (Office enforced policy; cannot change settings..)
When I am using the keyboard/mouse, windows treats them as user inputs & thus, the screen remains unlocked. However, when I am playing any game using only joystick, windows treats that as no-activity. Thus, the screen gets locked after the timeout.
Is there a way to prevent screen lock while using joystick based games?
As a work-around, I am currently playing some random video (muted) in background VLC, which prevents screen lock. But there should be a better way to handle this problem...
I could possibly write a script, which would simulate some keystrokes like {NUMLOCK}{NUMLOCK}
via sendkeys
. However, there is always a possibility of side-effect of this. e.g. That would prevent me from using these keys in my game options.
windows-7 screensaver joystick
add a comment |
My windows 7 system is set to lock the screen after 20 mins of inactivity. (Office enforced policy; cannot change settings..)
When I am using the keyboard/mouse, windows treats them as user inputs & thus, the screen remains unlocked. However, when I am playing any game using only joystick, windows treats that as no-activity. Thus, the screen gets locked after the timeout.
Is there a way to prevent screen lock while using joystick based games?
As a work-around, I am currently playing some random video (muted) in background VLC, which prevents screen lock. But there should be a better way to handle this problem...
I could possibly write a script, which would simulate some keystrokes like {NUMLOCK}{NUMLOCK}
via sendkeys
. However, there is always a possibility of side-effect of this. e.g. That would prevent me from using these keys in my game options.
windows-7 screensaver joystick
Yes it can be achieved in way you suggest. But did you check whether you can switch power plans? (Instead of changing power plan settings.) Sometimes High Performance power plan has energy-saving features disabled. And also: if they locked your power plan settings, did they leave unlocked the ability to install or run software not authorized by admins?
– miroxlav
Feb 23 '15 at 9:10
"Sometimes High Performance power plan has energy-saving features disabled" Good idea.. However, this setting is enforced as policy in screen-saver settings, not power-plan settings. "did they leave unlocked the ability to install or run software not authorized by admins" In general, yes, but those softwares cannot change the settings enforced by policy.
– anishsane
Feb 23 '15 at 9:51
Does anyone know of any windows API, to prevent screen lock, the one that media players like VLC use, while playing videos?
– anishsane
Feb 23 '15 at 9:52
add a comment |
My windows 7 system is set to lock the screen after 20 mins of inactivity. (Office enforced policy; cannot change settings..)
When I am using the keyboard/mouse, windows treats them as user inputs & thus, the screen remains unlocked. However, when I am playing any game using only joystick, windows treats that as no-activity. Thus, the screen gets locked after the timeout.
Is there a way to prevent screen lock while using joystick based games?
As a work-around, I am currently playing some random video (muted) in background VLC, which prevents screen lock. But there should be a better way to handle this problem...
I could possibly write a script, which would simulate some keystrokes like {NUMLOCK}{NUMLOCK}
via sendkeys
. However, there is always a possibility of side-effect of this. e.g. That would prevent me from using these keys in my game options.
windows-7 screensaver joystick
My windows 7 system is set to lock the screen after 20 mins of inactivity. (Office enforced policy; cannot change settings..)
When I am using the keyboard/mouse, windows treats them as user inputs & thus, the screen remains unlocked. However, when I am playing any game using only joystick, windows treats that as no-activity. Thus, the screen gets locked after the timeout.
Is there a way to prevent screen lock while using joystick based games?
As a work-around, I am currently playing some random video (muted) in background VLC, which prevents screen lock. But there should be a better way to handle this problem...
I could possibly write a script, which would simulate some keystrokes like {NUMLOCK}{NUMLOCK}
via sendkeys
. However, there is always a possibility of side-effect of this. e.g. That would prevent me from using these keys in my game options.
windows-7 screensaver joystick
windows-7 screensaver joystick
edited Feb 23 '15 at 9:04
anishsane
asked Feb 23 '15 at 8:47
anishsaneanishsane
5321518
5321518
Yes it can be achieved in way you suggest. But did you check whether you can switch power plans? (Instead of changing power plan settings.) Sometimes High Performance power plan has energy-saving features disabled. And also: if they locked your power plan settings, did they leave unlocked the ability to install or run software not authorized by admins?
– miroxlav
Feb 23 '15 at 9:10
"Sometimes High Performance power plan has energy-saving features disabled" Good idea.. However, this setting is enforced as policy in screen-saver settings, not power-plan settings. "did they leave unlocked the ability to install or run software not authorized by admins" In general, yes, but those softwares cannot change the settings enforced by policy.
– anishsane
Feb 23 '15 at 9:51
Does anyone know of any windows API, to prevent screen lock, the one that media players like VLC use, while playing videos?
– anishsane
Feb 23 '15 at 9:52
add a comment |
Yes it can be achieved in way you suggest. But did you check whether you can switch power plans? (Instead of changing power plan settings.) Sometimes High Performance power plan has energy-saving features disabled. And also: if they locked your power plan settings, did they leave unlocked the ability to install or run software not authorized by admins?
– miroxlav
Feb 23 '15 at 9:10
"Sometimes High Performance power plan has energy-saving features disabled" Good idea.. However, this setting is enforced as policy in screen-saver settings, not power-plan settings. "did they leave unlocked the ability to install or run software not authorized by admins" In general, yes, but those softwares cannot change the settings enforced by policy.
– anishsane
Feb 23 '15 at 9:51
Does anyone know of any windows API, to prevent screen lock, the one that media players like VLC use, while playing videos?
– anishsane
Feb 23 '15 at 9:52
Yes it can be achieved in way you suggest. But did you check whether you can switch power plans? (Instead of changing power plan settings.) Sometimes High Performance power plan has energy-saving features disabled. And also: if they locked your power plan settings, did they leave unlocked the ability to install or run software not authorized by admins?
– miroxlav
Feb 23 '15 at 9:10
Yes it can be achieved in way you suggest. But did you check whether you can switch power plans? (Instead of changing power plan settings.) Sometimes High Performance power plan has energy-saving features disabled. And also: if they locked your power plan settings, did they leave unlocked the ability to install or run software not authorized by admins?
– miroxlav
Feb 23 '15 at 9:10
"Sometimes High Performance power plan has energy-saving features disabled" Good idea.. However, this setting is enforced as policy in screen-saver settings, not power-plan settings. "did they leave unlocked the ability to install or run software not authorized by admins" In general, yes, but those softwares cannot change the settings enforced by policy.
– anishsane
Feb 23 '15 at 9:51
"Sometimes High Performance power plan has energy-saving features disabled" Good idea.. However, this setting is enforced as policy in screen-saver settings, not power-plan settings. "did they leave unlocked the ability to install or run software not authorized by admins" In general, yes, but those softwares cannot change the settings enforced by policy.
– anishsane
Feb 23 '15 at 9:51
Does anyone know of any windows API, to prevent screen lock, the one that media players like VLC use, while playing videos?
– anishsane
Feb 23 '15 at 9:52
Does anyone know of any windows API, to prevent screen lock, the one that media players like VLC use, while playing videos?
– anishsane
Feb 23 '15 at 9:52
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
You can use the SetThreadExecutionState
function, as provided by Python's ctypes module, as part of a standalone Python application you can run in the background and exit with Ctrl+C. (Thanks to the answer by @misha256 for explaining the use of this function!)
import ctypes
from time import sleep
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
# CONTINUOUS repeats the action until the application closes,
# SYSTEM_REQUIRED 'forces the system to be in the working state by resetting the system idle timer.'
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
# wait until broken
while True:
# attempt to run the following code
try:
sleep(1) # thanks @anishsane
except(KeyboardInterrupt): # catch a Ctrl+C
break # stop waiting
I've built this script for Windows. Visit the GitHub release page here.
1
Instead of0
as placeholder, the standard way ispass
.
– anishsane
Dec 21 '18 at 3:19
1
Also, it is better to keep some sleep() instead of pass. Otherwise, this will busy-wait and consume CPU. You can even sleep for hours there.
– anishsane
Dec 22 '18 at 5:49
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f881324%2fprevent-windows-screen-lock-when-playing-with-joystick%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
answered Feb 26 '15 at 10:47
misha256misha256
8,55164061
8,55164061
add a comment |
add a comment |
You can use the SetThreadExecutionState
function, as provided by Python's ctypes module, as part of a standalone Python application you can run in the background and exit with Ctrl+C. (Thanks to the answer by @misha256 for explaining the use of this function!)
import ctypes
from time import sleep
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
# CONTINUOUS repeats the action until the application closes,
# SYSTEM_REQUIRED 'forces the system to be in the working state by resetting the system idle timer.'
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
# wait until broken
while True:
# attempt to run the following code
try:
sleep(1) # thanks @anishsane
except(KeyboardInterrupt): # catch a Ctrl+C
break # stop waiting
I've built this script for Windows. Visit the GitHub release page here.
1
Instead of0
as placeholder, the standard way ispass
.
– anishsane
Dec 21 '18 at 3:19
1
Also, it is better to keep some sleep() instead of pass. Otherwise, this will busy-wait and consume CPU. You can even sleep for hours there.
– anishsane
Dec 22 '18 at 5:49
add a comment |
You can use the SetThreadExecutionState
function, as provided by Python's ctypes module, as part of a standalone Python application you can run in the background and exit with Ctrl+C. (Thanks to the answer by @misha256 for explaining the use of this function!)
import ctypes
from time import sleep
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
# CONTINUOUS repeats the action until the application closes,
# SYSTEM_REQUIRED 'forces the system to be in the working state by resetting the system idle timer.'
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
# wait until broken
while True:
# attempt to run the following code
try:
sleep(1) # thanks @anishsane
except(KeyboardInterrupt): # catch a Ctrl+C
break # stop waiting
I've built this script for Windows. Visit the GitHub release page here.
1
Instead of0
as placeholder, the standard way ispass
.
– anishsane
Dec 21 '18 at 3:19
1
Also, it is better to keep some sleep() instead of pass. Otherwise, this will busy-wait and consume CPU. You can even sleep for hours there.
– anishsane
Dec 22 '18 at 5:49
add a comment |
You can use the SetThreadExecutionState
function, as provided by Python's ctypes module, as part of a standalone Python application you can run in the background and exit with Ctrl+C. (Thanks to the answer by @misha256 for explaining the use of this function!)
import ctypes
from time import sleep
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
# CONTINUOUS repeats the action until the application closes,
# SYSTEM_REQUIRED 'forces the system to be in the working state by resetting the system idle timer.'
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
# wait until broken
while True:
# attempt to run the following code
try:
sleep(1) # thanks @anishsane
except(KeyboardInterrupt): # catch a Ctrl+C
break # stop waiting
I've built this script for Windows. Visit the GitHub release page here.
You can use the SetThreadExecutionState
function, as provided by Python's ctypes module, as part of a standalone Python application you can run in the background and exit with Ctrl+C. (Thanks to the answer by @misha256 for explaining the use of this function!)
import ctypes
from time import sleep
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
# CONTINUOUS repeats the action until the application closes,
# SYSTEM_REQUIRED 'forces the system to be in the working state by resetting the system idle timer.'
ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)
# wait until broken
while True:
# attempt to run the following code
try:
sleep(1) # thanks @anishsane
except(KeyboardInterrupt): # catch a Ctrl+C
break # stop waiting
I've built this script for Windows. Visit the GitHub release page here.
edited Dec 22 '18 at 15:27
answered Dec 19 '18 at 21:27
HewwoCrazinessHewwoCraziness
416
416
1
Instead of0
as placeholder, the standard way ispass
.
– anishsane
Dec 21 '18 at 3:19
1
Also, it is better to keep some sleep() instead of pass. Otherwise, this will busy-wait and consume CPU. You can even sleep for hours there.
– anishsane
Dec 22 '18 at 5:49
add a comment |
1
Instead of0
as placeholder, the standard way ispass
.
– anishsane
Dec 21 '18 at 3:19
1
Also, it is better to keep some sleep() instead of pass. Otherwise, this will busy-wait and consume CPU. You can even sleep for hours there.
– anishsane
Dec 22 '18 at 5:49
1
1
Instead of
0
as placeholder, the standard way is pass
.– anishsane
Dec 21 '18 at 3:19
Instead of
0
as placeholder, the standard way is pass
.– anishsane
Dec 21 '18 at 3:19
1
1
Also, it is better to keep some sleep() instead of pass. Otherwise, this will busy-wait and consume CPU. You can even sleep for hours there.
– anishsane
Dec 22 '18 at 5:49
Also, it is better to keep some sleep() instead of pass. Otherwise, this will busy-wait and consume CPU. You can even sleep for hours there.
– anishsane
Dec 22 '18 at 5:49
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f881324%2fprevent-windows-screen-lock-when-playing-with-joystick%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Yes it can be achieved in way you suggest. But did you check whether you can switch power plans? (Instead of changing power plan settings.) Sometimes High Performance power plan has energy-saving features disabled. And also: if they locked your power plan settings, did they leave unlocked the ability to install or run software not authorized by admins?
– miroxlav
Feb 23 '15 at 9:10
"Sometimes High Performance power plan has energy-saving features disabled" Good idea.. However, this setting is enforced as policy in screen-saver settings, not power-plan settings. "did they leave unlocked the ability to install or run software not authorized by admins" In general, yes, but those softwares cannot change the settings enforced by policy.
– anishsane
Feb 23 '15 at 9:51
Does anyone know of any windows API, to prevent screen lock, the one that media players like VLC use, while playing videos?
– anishsane
Feb 23 '15 at 9:52