Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: [CMD] Backlight adjust script based on time of day

16 Oct 2014   #1
tweakradje

win7
 
 
[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



My System SpecsSystem Spec
.
16 Oct 2014   #2
Layback Bear

Windows 7 Pro. 64/SP-1
 
 

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 System SpecsSystem Spec
17 Oct 2014   #3
tweakradje

win7
 
 

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 System SpecsSystem Spec
.

Reply

 [CMD] Backlight adjust script based on time of day




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
1 time startup script????
Hi folks, Short details: We run server 2008r2 and windows 7 clients. Folder redirection (policies) fail after a recent windows update. after searching i found a solution to add some register keys. So the remaining problem persists, I don't want to go a run the .reg file manually on 100+...
General Discussion
Backlight - Decreasing backlight Level more
New to the forum so Hello everyone. I understand how to turn down the level of brightness through backlight control but how do I decrease the level even further? The slider in the brightness bar is all the way down (left) yet at nights the light from backlights are too bright! Couldn't...
Graphic Cards
Volume control based on time of day?
Are there any utilities that can adjust the volume control based on the time of day? If I turn the PC on before work at 5am, I don't want it loud. If the wife or kids use the PC the volume control could be at any setting. Basically I want to be able to tell the computer... ... at 9am, put...
Sound & Audio
Change desktop backgrounds automatically based on time and weather?
I want it to integrate with the default weather desktop gadget so that the current weather and/or time is reflected in my desktop. If possible I would like it to have a GUI so you can easily change what backgrounds/themes associate with each feature. I wouldn't mind doing the coding on this...
Customization
Restart time script problem
I was using the restart script from the above stickied reboot time post. It was working fine now all of a sudden it says Can't Fine script engine "VBScript" for script I havnt done anything but uninstall mcafee and install comodo firewall with avast anti virus. Under associate programs it says...
Performance & Maintenance


Our Sites

Site Links

About Us

Find 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 10:04.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App