-
1 Attachment(s)
VB6 - Sunset, Turn Monitor Off
Renamed from Lights Out to Sunset to avoid name collision with another product.
One of the things I find handy in Windows Media Player on Windows Mobile 6.x is the ability to assign a "lights out" function to any spare key on your phone, like the "down" button on the D-pad. This shuts off the LCD backlight saving power while listening to music, podcasts, etc.
Playing with Windows 8 and Windows 7 Tablet PCs I noticed there doesn't seem to be anything for doing this. At least not that I've uncovered. I was sort of expecting a gesture or something, but nope.
So I looked around for a small utility and found nothing but horrid things dependent on .Net Frameworks and bloated in size themselves. Life is too short and disk is usually SSD and not a cheap resource, so I did one better.
This program is a very simple VB6 program that compiles down to an 8K EXE. Run it and it shuts the monitor "off" saving power. Just drop it on your Desktop or place it somewhere else and pin it to the QuickLaunch Toolbar (or Taskbar if you haven't re-enabled QuickLaunch).
Start your music and tap on Sunset. Pretty much any gesture brings the LCD back "on."
Just unzip the attached archive and right-click, Make or open it in the IDE and Make it there. Deploy as you will, no dependencies aside from the preinstalled VB6 runtime libraries.
Should be testable on your desktop with no trouble. Wiggle the mouse to bring your monitor(s) back on.
Sunset Binary.zip is here. You may want to right-click, Properties... then Unblock to avoid a security prompt every run!
-
Re: VB6 - Lights Out, Turn Monitor Off
Cool! I think I might be mistaken but isn't there an option on Windows desktop pc to do this?
-
Re: VB6 - Lights Out, Turn Monitor Off
Some desktops may have a vendor-assigned hot key. Usually one of the extra, non-standard keys on an OEM keyboard that a vendor Service monitors. Many laptops have an Fn-shift key that adds special functions to other regular keys (hold Fn press F4 to suspend, etc.).
Even a Winkey-combo doesn't help on a tablet device though: no keyboard. Many have only a very few control buttons for things like volume up/down, Start (menu), etc.
-
Re: VB6 - Lights Out, Turn Monitor Off
Quote:
Originally Posted by
dilettante
So I looked around for a small utility and found nothing but horrid things dependent on .Net Frameworks and bloated in size themselves.
I guess it is lucky Visual Basic 6.0 still works on those systems? As you say the alternative the .NET which isn't really that small.
-
Re: VB6 - Lights Out, Turn Monitor Off
Quote:
Originally Posted by
Nightwalker83
I guess it is lucky Visual Basic 6.0 still works on those systems? As you say the alternative the .NET which isn't really that small.
I thought it was funny there are other tools that do just this and are from 85 to 100 KB!
This has only been tested on Vista and on Windows 8 Developer Preview so far.
For all I know there's a much shorter way to do the same thing by making a shortcut that runs RunDLL32 to make the simple API call required.
-
Re: VB6 - Lights Out, Turn Monitor Off
Cool! simple, small size, and ... work great!! :thumb:
-
Re: VB6 - Lights Out, Turn Monitor Off
Interesting oddity...
I normally use the version 8.0 LINK.EXE for VB6 instead of the version 6.0 that ships with and installs as part of VB6. [Note that to do this means copying a few more DLLs into the VB98 folder as well as LINK.EXE itself.]
Well a bit ago I was messing around with creating debug symbols during compiles and ran into a problem with versioning and one of the 8.0 LINK.EXE-related DLLs. So I swapped the original 6.0 LINK.EXE in and all was well.
However when I went back and recompiled Lights Out I found I now got a 16K EXE!
Going back to the newer 8.0 LINK.EXE (which works fine for most purposes) I am back down to an 8K EXE again.
-
Re: VB6 - Lights Out, Turn Monitor Off
Quote:
Originally Posted by
dilettante
I thought it was funny there are other tools that do just this and are from 85 to 100 KB!
Well, I don't know about you but I would hate to see amount of support files needed if that were .Net code. It seems the more advanced we become coding wise (COM, .NET, etc) the dumber we become in the fact that support files get bigger and bigger it comparison to the amount of code written.
-
Re: VB6 - Lights Out, Turn Monitor Off
I suppose. It's like adding power steering, automatic transmission, GPS, heated seats, satellite radio, etc. to vehicles.
-
Re: VB6 - Sunset, Turn Monitor Off
Rats, there was another one out there with the same name. Now calling this one Sunset.
Names get harder to come up with every day!
-
Re: VB6 - Sunset, Turn Monitor Off
Ahh, this may be part of the reason for the size difference:
DOC: /OPT:NOWIN98 Linker Option Not Described in Linker Reference
As described there, the default used to be /OPT:WIN98 and in later versions of the Linker it is /OPT:NOWIN98 which was the standard before (and now after) Windows 98 and VS 6.0.
-
Re: VB6 - Lights Out, Turn Monitor Off
to #7 hi, excuse me could you tell me which are the related DLLs ?
-
Re: VB6 - Sunset, Turn Monitor Off
I think you need msdis150.dll and mspdb80.dll. You also need the link.exe.config file. Even though its actual contents don't matter for "real" program linking, i.e. not .Net managed code, the 8.0 linker requires the file to be there.
However...
You should note that when you use version 8.0 of link.exe attempts to compile a VB6 DLL may fail with errors. I've had to flip them (6.0 and 8.0 versions) back and forth a few times.
-
Re: VB6 - Sunset, Turn Monitor Off
In answer to a PM:
Yes, Sunset works fine in Windows 10. I use it every day and haven't had to make any modifications.
-
Re: VB6 - Sunset, Turn Monitor Off
And even on Windows 11
I am thinking to add it to all my apps (several thousands of clients), to reduce consumption of energy (but is it true?)
-
Re: VB6 - Sunset, Turn Monitor Off
Most LCD monitors should turn their backlights off so it should save power, battery life, etc.
-
Re: VB6 - Sunset, Turn Monitor Off
Nice utility Dilettante! Come in handy to listening music on my netbook.
-
Re: VB6 - Sunset, Turn Monitor Off
The only problem is that as soon as you move the mouse, the monitor is automatically turned on again.
-
Re: VB6 - Sunset, Turn Monitor Off
Uh, that's how it is supposed to work. It's a user tool, not a technique for use by ransomware.
-
Re: VB6 - Sunset, Turn Monitor Off
Quote:
Originally Posted by
dilettante
Uh, that's how it is supposed to work. It's a user tool, not a technique for use by ransomware.
The problem is that the mouse sometimes moves by its own, turning the monitor on again (that's what happened to me). So it cannot be used to avoid having to press the monitor physical on/off button.
About ramsonware, you must know much better than me how to send them.
-
Re: VB6 - Sunset, Turn Monitor Off
use with LockWindowStation will be better:
Code:
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function LockWorkStation Lib "user32.dll" () As Long
Sub Main()
LockWorkStation
SendMessage &HFFFF&, &H112&, &HF170&, ByVal 2&
End Sub
-
Re: VB6 - Sunset, Turn Monitor Off
It depends on what you are after. The original program is just an easy way to invoke power savings and avoid burn-in by putting the screen to sleep. Obviously other alternatives are available, but some are silly since we already have simple ways to invoke them:
Quote:
LockWorkStation
This function has the same result as pressing Ctrl+Alt+Del and clicking Lock Workstation. To unlock the workstation, the user must log in.