Turn Windows Monitor/LCD Off (Assembly Language Version) — Announcing LCDoff

I recently upgraded my trusty ThinkPad T42 to Windows 7.  Unfortunately, the screen-off keystroke no longer works.  Some quick Googling showed that people made their own handlers in C#.  Well, that sucks if you don’t have the .net CLR.  This is not a problem on Windows 7, but I also wanted to try out my Assembly skills since they were all just calling standard Win32 APIs.

Download LCDOff.exe

This should work on fairly old systems, back to Windows NT 3.1 and Windows 95, unlike the C# versions.  It is also 7.5kb vs 85kb.

I wrote it in MASM using the Irvine library for convenience.  Optimized with http://upx.sourceforge.net/

TITLE Monitor Off (main.asm)
; Description: This program turns off your monitor (power saving mode)
; Revision date: 2 November 2009

INCLUDE Irvine32.inc
INCLUDELIB Kernel32.lib
INCLUDELIB User32.lib

SendMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORD
GetConsoleWindow PROTO

WM_SYSCOMMAND = 0112h
SC_MONITORPOWER = 0F170h
OFF = 2

.data
msg BYTE "Monitor off.  Program from Kev009.com",0dh,0ah,0

.code
main PROC

call Clrscr

; Get our window handle to send the event to
INVOKE GetConsoleWindow
; The handle is now in eax
INVOKE SendMessageA, eax, WM_SYSCOMMAND, SC_MONITORPOWER, OFF

mov	 edx,OFFSET msg
call WriteString

exit
main ENDP
END main

I’ve set up a project page at http://www.kev009.com/wp/projects/lcdoff/ if there ever need to be updates.

Be Sociable, Share!
  • Twitter
  • email
  • StumbleUpon
  • Delicious
  • LinkedIn
  • HackerNews
  • Reddit
  • Facebook

Related posts:

  1. LCDoff.exe This program will disable your LCD or monitor when executed. ...
  2. Linus and Windows 7 This is awesome....
  3. Windows 7 has definite backlight problems (“Black Screen of Death”) There is definitely a problem in Windows 7 RTM with...
  4. Video of Windows 7 Black Screen of Death Here’s a video to accompany my previous blog post Windows...

5 thoughts on “Turn Windows Monitor/LCD Off (Assembly Language Version) — Announcing LCDoff

  1. Pingback: Windows 7 has definite backlight problems (”Black Screen of Death”) | Kev009.com

  2. LCDoff is the best smallest utility that works best, even with Windows 7, and Thinkpad with Extended monitor via docking station.
    Cheers!

  3. Works like a charm. Nice job!

    26% power savings:

    My thinkpad z60m is 30 watts at idle with screen on
    and 22 watts with the screen off.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>