The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Mark Jones on June 09, 2005, 09:38:58 PM

Title: Monitor Standby
Post by: Mark Jones on June 09, 2005, 09:38:58 PM
 Hello, anyone know a way to put the monitor into standby mode? MSDN seems to say "video and miniport driver (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/graphics/hh/graphics/VideoMiniport_Functions_22a6c5ae-0c31-48a6-8882-06edfea32c1a.xml.asp)". Is there nothing easier? Thanks.
Title: Re: Monitor Standby
Post by: GregL on June 10, 2005, 03:23:16 AM
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   

Title: Re: Monitor Standby
Post by: Mark Jones on June 10, 2005, 06:58:15 AM
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.
Title: Re: Monitor Standby
Post by: Tedd on June 13, 2005, 04:51:33 PM
Throw away code.. :toothy

[attachment deleted by admin]
Title: Re: Monitor Standby
Post by: Phil on June 13, 2005, 06:29:45 PM
Thanks Tedd :U
Title: Re: Monitor Standby
Post by: Tedd on June 14, 2005, 10:17:21 AM
Small correction.. :red


;;- WM_DESTROY --------------------------------------------------------------------------------------
    .ELSEIF (eax==WM_DESTROY)
        invoke Shell_NotifyIcon,NIM_DELETE,ADDR iconData
        invoke PostQuitMessage, NULL
Title: Re: Monitor Standby
Post by: brixton on June 14, 2005, 10:19:05 AM
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
Title: Re: Monitor Standby
Post by: 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

Alternatively, there's always: http://msdn.microsoft.com/library
Title: Re: Monitor Standby
Post by: brixton on June 14, 2005, 12:31:26 PM
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  :'(