[CMD] Backlight adjust script based on time of day


  1. Posts : 31
    win7
       #1

    [CMD] Backlight adjust script based on time of day


    Hi,

    I couldn't find a good tool for adjusting my laptop backlight automatically based on the time of day.
    So I decided to give it a shot and created this CMD file. It is very rough calculus but it kinda works.
    Still need to do the maths for latitude/month correction (perhaps someone has a bright idea?)

    Code:
    @echo off
    
    REM ### Tweakradje 2014 
    REM ### Calculating sunrise/set and adjust backlight (very rough!)
    REM ### Run it with windows scheduler e.g. every hour
    
    REM  BACKLMAX   12:00
    REM              /\ 
    REM             /  \     6:00
    REM           -/--18:00--/-- MONTH/LAT LINE UP/DOWN (HORIZON)
    REM           6:00   \  /
    REM                   \/
    REM  BACKLMIN        24:00
    
    title Adjusting Backlight based on Time of day...
    
    SET LATITUDE=52
    SET MONTH=
    SET HOUR=
    REM BACKLDIM=10 minimal in steps of 5 upwards
    REM BACKLMIN=20 minimal in steps of 5 upwards
    REM BACKLMAX=100 maximal
    REM DIMTIMEOUT=60 minimal in seconds
    SET BACKLMAX=80
    SET BACKLMIN=30
    SET BACKLDIM=10
    SET DIMTIMEOUT=120
    SET /A BACKLDIF=%BACKLMAX%-%BACKLMIN%
    SET BACKLEVEL=
    
    REM Get the month, %DATE% like wo 15-10-2014
    Set MONTH=%date:~6,2%
    REM Get the Hour, %TIME% like 23:12:38,60
    Set HOUR=%time:~,2%
    
    REM For 24 hour Simulation REM next "Goto SKIP_SIMULATE" line
    Goto SKIP_SIMULATE
    
    FOR /L %%H IN (0,1,24) DO Set HOUR=%%H & Call :SKIP_SIMULATE
    rem Pause
    Exit /b
    
    :SKIP_SIMULATE
    REM ### BACKLEVEL goes from 0 > BACKLDIF/2 > BACKLDIF > BACKLDIF/2 > 0 by the HOUR
    If %HOUR% LEQ 24 Set /A BACKLEVEL=2*%BACKLDIF%-%BACKLDIF%/12*%HOUR%
    If %HOUR% LEQ 12 Set /A BACKLEVEL=%BACKLDIF%/12*%HOUR%
    
    Set /A BACKLEVEL=%BACKLMIN%+%BACKLEVEL%
    Echo Backlight Level at %HOUR%h: %BACKLEVEL%
    
    Powercfg.exe -SetAcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIM %DIMTIMEOUT%
    Powercfg.exe -SetDcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIM %DIMTIMEOUT%
    Powercfg.exe -SetAcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIMLEVEL %BACKLDIM%
    Powercfg.exe -SetDcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEODIMLEVEL %BACKLDIM%
    Powercfg.exe -SetAcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEONORMALLEVEL %BACKLEVEL%
    Powercfg.exe -SetDcValueIndex SCHEME_CURRENT SUB_VIDEO VIDEONORMALLEVEL %BACKLEVEL%
    Powercfg.exe /s SCHEME_CURRENT
    
    Exit /b
    Last edited by tweakradje; 31 Oct 2014 at 16:12.
      My Computer


  2. Posts : 25,847
    Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
       #2

    Just a thought.

    Time of day or night really doesn't mean much unless one is outside using their computer.

    The lighting in a room or building that the laptop is being used in would be my concern.

    Changing the backlight with time might not match the lighting conditions where the computer is being used.
      My Computer


  3. Posts : 31
    win7
    Thread Starter
       #3

    Hi, thanks for your reply.

    Please don't take this script too seriously :)

    A proper light/lux sensor in your laptop will do it ofcourse.

    Cheers
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 20:12.
Find Us