Turn off Monitor

  • Thread starter Thread starter Herbert Seidenberg
  • Start date Start date
H

Herbert Seidenberg

Can the monitor be turned on and off depending on the value of
real-time data inputted at COM1 and processed by Excel?
 
Herbert Seidenberg said:
Can the monitor be turned on and off depending on the value of
real-time data inputted at COM1 and processed by Excel?

I can't comment about the data feed from COM1 into Excel, but once Excel
processes it, Excel could run the blank screen saver, which would appear as
if it turned off the monitor. There may be API calls to switch the monitor
to power saver mode.
 
Harlan Grove said:
There may be API calls to switch the monitor
to power saver mode.

There is a first time for everything. Today I can not only confirm, but even
provide detail to, a post by Harlan.

Option Explicit

Const SC_MONITORPOWER = &HF170&
Const WM_SYSCOMMAND = &H112&
Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Sub Stby()
'Standby monitor:
Dim x As Long
x = SendMessage(Application.hWnd, _
WM_SYSCOMMAND, SC_MONITORPOWER And 65520, 1&)
End Sub

Sub Onagain()
'Turn on monitor:
Dim x As Long
x = SendMessage(Application.hWnd, _
WM_SYSCOMMAND, SC_MONITORPOWER And 65520, -1&)
End Sub

Sub Test()
Call Stby
'Application.OnTime (Now + TimeSerial(0, 0, 10)), "Onagain"
End Sub

Best wishes Harald
 
Thanks, that worked perfectly.
This is going to extend the battery life of my mobile application a lot.
 
Back
Top