[CMD] Backlight adjust script based on time of day

tweakradje

New member
Local time
7:43 AM
Messages
31
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?) :confused:

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:

My Computer My Computer

OS
win7
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 My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home made Desktop
OS
Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
CPU
Intel i7-6800K @ 4.3
Motherboard
ASUS X-99 Deluxe II
Memory
Corsair Platinum 16 gig @2400
Graphics Card(s)
EVGA GTX 1070 OC
Monitor(s) Displays
Asus 27" LED LCD/VE278Q
Screen Resolution
1920-1080 or 1280-720 HDMI
Hard Drives
INTEL SSD 730-240 Gb Sata 3.0/
PSU
EVGA Platium 1200W
Case
Phanteks Luxe Tempered Glass 8 fans/ one radiator
Cooling
XSPC/ Water Cooled CPU
Keyboard
Das 4 Professional
Mouse
Logitech M705/MX Anywhere 2-S
Internet Speed
100 mbits
Antivirus
Microsoft Security Essentials/ Malwarebytes Premium 3.0/ SAS
Browser
I.E. 11 default/Firefox/ ISP Time Warner Cable/Spectrum
Other Info
LG BluRay Burner/
Sound system-KLipsch-THX/
Icy Dock ssd Hot Swap bays.
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 My Computer

OS
win7
Back
Top