Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings to all,

I need to be able to block or disable a call from the monitor after a set amount of time. I've been working with 3 PC's that have real-time data being displayed. They rarely require any user intervention...only an initial logon after updates.

What I've tried to do so far is; clearing the Registry settings for disabling the screensaver, disabling the ECO mode on the monitor (has a 5-60 minute timeout choice that cannot be turned off, or set to 0), and creating a .vbs script that opens an instance of notepad and types data before closing out (see below).
VBScript
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "Notepad"
WScript.Sleep 300 
For i = 1 To 1
  WshShell.SendKeys "awake"
  WshShell.SendKeys "{ENTER}"
Next
  WshShell.SendKeys "%f"
  WshShell.SendKeys "x"
  WshShell.SendKeys "n"

The problem with this is that occasionally it doesn't close out of Notepad, so another instance is opened every time the scheduled task runs the vbs script. There was also a Mouse moving script that I wrote, but either I failed at writing legit code, or it failed to block it the subsequent times it ran?

Any direction on how I could use SystemParametersInfo to block the timeout from occurring/resetting on a regular variable? Under "powerprof" there are some that I'm not familiar with, but I'm hoping that one of them may be able to stave this off.

This code was posted by Jockersoft http://www.codeproject.com/Messages/890393/disable-poweroff-function.aspx[], but I'm unsure if something similar to this could be used outside of a specific application? Could I run said code when an application opens, or what would be the best way to use in conjunction with an already compiled app?

VBScript
[DllImport("Kernel32.dll")]
private static extern uint SetThreadExecutionState
(
  uint esFlags
); 
 
private const uint ES_SYSTEM_REQUIRED = 0x00000001;
private const uint ES_DISPLAY_REQUIRED = 0x00000002;
private const uint ES_CONTINUOUS = 0x80000000; 
 
private void disablePoweroff()
{
  SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
} 
 
private void enablePoweroff()
{
  SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
}

Thank you for any advice or direction you can provide,
Posted
Updated 16-Oct-11 5:36am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900