Results 1 to 22 of 22

Thread: VB6 - Sunset, Turn Monitor Off

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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!
    Attached Files Attached Files
    Last edited by dilettante; Oct 11th, 2011 at 01:46 PM. Reason: added link to compiled binary, renamed program

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    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?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: VB6 - Lights Out, Turn Monitor Off

    Quote Originally Posted by dilettante View Post
    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.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 - Lights Out, Turn Monitor Off

    Quote Originally Posted by Nightwalker83 View Post
    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.
    Last edited by dilettante; Oct 10th, 2011 at 09:57 PM.

  6. #6

    Re: VB6 - Lights Out, Turn Monitor Off

    Cool! simple, small size, and ... work great!!

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  8. #8
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: VB6 - Lights Out, Turn Monitor Off

    Quote Originally Posted by dilettante View Post
    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.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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!

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  12. #12
    Fanatic Member
    Join Date
    Sep 2010
    Location
    Italy
    Posts
    678

    Re: VB6 - Lights Out, Turn Monitor Off

    to #7 hi, excuse me could you tell me which are the related DLLs ?

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  15. #15
    Fanatic Member
    Join Date
    Jan 2015
    Posts
    596

    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?)

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: VB6 - Sunset, Turn Monitor Off

    Most LCD monitors should turn their backlights off so it should save power, battery life, etc.

  17. #17

  18. #18
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    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.

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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.

  20. #20
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: VB6 - Sunset, Turn Monitor Off

    Quote Originally Posted by dilettante View Post
    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.

  21. #21
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    323

    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

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    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:

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width