Turn off Monitor

  • Thread starter Herbert Seidenberg
  • 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?
 
H

Harlan Grove

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.
 
H

Harald Staff

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
 
H

Herbert Seidenberg

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top