I need to turn a monitor on after it resumes/wakes from sleep. The only way it seems to do this is by mouse movement or keypress. Is there any way in C on Windows 7 to simulate this so 开发者_开发百科the monitor wakes up?
There is a utility named Caffeine that does this... I only mention it because it sends the F15 key every 59 seconds... so that may be a better key press to send.
I viewed this as it has the batch tag on it, but I see that you want to use C ? In VBS you can easily use the follwing to send a keypress. This can be called from a batch file or if you are compiling something in C It should not be hard either.
Set objShell = CreateObject("WScript.Shell")
Do While True
objShell.SendKey("+")
WScript.Sleep 60000
Loop
//Note that the key being sent is the + key. You can change this as well as the time it waits to send the keypress which is currently 60000 (1 second would be 1000) If you call this at the start of your program it will remain running and will send the keystroke to the system until the vbs script is terminated.
You could also use a key that wont likely hinder someone who is typing at the time, such as the numlock key.
精彩评论