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.
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.
Related posts:
- Windows 7 has definite backlight problems (“Black Screen of Death”) There is definitely a problem in Windows 7 RTM with...
- Announcing boo2pdf I’ve just uploaded a beta of boo2pdf, an IBM BookManager...
November 27th, 2009 at 1:06 am
Hey Kevin, thank you for your comment, I really appreciate it. I’ve answered to it.
Greetings.
December 11th, 2009 at 6:03 pm
[...] can trigger it readily with my LCDoff utility, though it will also happen organically with Windows’ automatic power [...]
January 5th, 2010 at 10:25 am
Thanks for the program, it works great!