0
I would like my pc to automatically sleep when I turn the tv off. How can this be accomplished? I would also like the htpc to power on when the tv is turned on as well if possible
Computer- Windows 8.1 Gigabyte B85 GTX 650
0
I would like my pc to automatically sleep when I turn the tv off. How can this be accomplished? I would also like the htpc to power on when the tv is turned on as well if possible
Computer- Windows 8.1 Gigabyte B85 GTX 650
0
Expanding on Keltari's comment, the following VBScript loops and every second reports whether or not the screen is on.
Do
WScript.Sleep 1000
WScript.Echo "Screen is on = " & ScreenOn
Loop
Function ScreenOn()
Dim objWMIService, colItems, objItem
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)
ScreenOn = False
For Each objItem in colItems
If objItem.Availability = 3 Then
ScreenOn = True
Exit For
End If
Next
On Error Goto 0
End Function
You should save it (eg. as screenstatus.vbs
) and run it from the command line using cscript screenstatus.vbs
).
If all goes well, then "True" will be displayed every second and when you turn off the screen then it'll flip to "False". You'll obviously need to turn on the screen to double check this!
Assuming this goes well, then you can change the loop at the top to something like:
If ScreenOn() = False Then
' Call command here to sleep computer
End If
and then schedule the script to run on a regular basis (eg. every 15 minutes).
Your machine won't go to sleep immediately, but will turn off the next time the script is run (which, in the example I provided, will be within 15 minutes).
0
This actually should be possible with some scripting or coding.
There is a WMI Win32_DesktopMonitor class that has an property called "Availability."
The availability property lists 17 possible states the monitor can be in. You will probably want want to check for the value of 0x03 (Running or Full Power). However, you would have to play with the returning values from your TV to see what is best.
A script or program can be written to run at a frequency you choose, detect the state of the TV, then send a sleep command to the OS if it detects the TV is off.
Im primarily a osx/linux user can you elaborate whats necessary for the script in windows? – polar – 2015-09-07T19:05:26.037
vbscript or powershell - scripting built into windows. or if you want to want write a real program, you can download visual studio express for free – Keltari – 2015-09-07T19:44:43.077
By "tv", do you mean the monitor? – Xavierjazz – 2015-09-07T18:56:43.540
Its an htpc, so its connected to a tv – polar – 2015-09-07T19:04:54.957