News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Monitor Standby

Started by Mark Jones, June 09, 2005, 09:38:58 PM

Previous topic - Next topic

Mark Jones

 Hello, anyone know a way to put the monitor into standby mode? MSDN seems to say "video and miniport driver". Is there nothing easier? Thanks.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

GregL

Mark,

I don't know if this is exactly what you want, but you can do this:

.486
.model flat, stdcall
option casemap:none


include c:\masm32\include\windows.inc

include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc

includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\user32.lib

MONITOR_ON        EQU -1
MONITOR_LOW_POWER EQU  1
MONITOR_OFF       EQU  2

.data

    hWnd DWORD 0

.code

start:

    invoke GetForegroundWindow
    mov hWnd, eax
   
    invoke SendMessage, hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF
   
    invoke Sleep, 4000
   
    invoke SendMessage, hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON
   
    invoke ExitProcess, 0
   
end start

end   


Mark Jones

Aaaaha! Yes Greg, that does exactly what I want. :) Now I can quit powering off my monitor when it should be sleeping instead. :bg

(I miss the old Win9x screensaver where you can park the mouse pointer in the top-right to force monitor standby...) now I can just do the same thing with an accelerator key toggle. Thanks! :U  I'll post a usable app once I get it completed.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Tedd

Throw away code.. :toothy

[attachment deleted by admin]
No snowflake in an avalanche feels responsible.

Phil


Tedd

Small correction.. :red


;;- WM_DESTROY --------------------------------------------------------------------------------------
    .ELSEIF (eax==WM_DESTROY)
        invoke Shell_NotifyIcon,NIM_DELETE,ADDR iconData
        invoke PostQuitMessage, NULL
No snowflake in an avalanche feels responsible.

brixton

How does one find these messages?  Are they all documented somewhere?  I know many messages are in Win32.hlp, but it doesn't even have WM_SYSCOMMAND in there.  Can you point me in the right direction?

Thanks  :bg
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

Tedd

WM_SYSCOMMAND is in my win32.hlp :eek
Either I have a strange version, or you do :bdg

Alternatively, there's always: http://msdn.microsoft.com/library
No snowflake in an avalanche feels responsible.

brixton

Quote from: Tedd on June 14, 2005, 10:29:52 AM
WM_SYSCOMMAND is in my win32.hlp :eek
Either I have a strange version, or you do :bdg
:eek.. And I thought I had a good version of Win32.hlp  :'(
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..