Tur-Another Idle Volume Adjuster by Turranius

Purpose: Lowers or mutes the master volume after a defined amount of time.

Reason : Originally ment for HyperSpin to lower/mute the volume after you have not touched anything for some time.
         It is totally stand-alone though, so any reason you can think of.

Usage  : You only need the exe file. The first time you run it, it will create the Settings.ini file and quit.
         Change the Settings.ini file as you want it configured and restart it. All the options are described below.
         If you mess something up in Settings.ini, delete and and a new one will be created on next run.

         You may want to disable the sound for "Default Beep" in Windows before running this or if you get a 
         "pling" each time it changes the volume.

Disclamer: You configure the volume in this app. If you blow your eardrums by configuring it to raise the volume
           to 100% or similar, I can not be held responsible. Please read through the options.

Limitation: It actually uses the volume mixer app to change the volumes so it will be started and stopped when the
            volume needs to be modified. In Debug mode, the volume control will be shown but not otherwise.
            This causes two things to happen.
            1: If you manually open the volume control, it might close on you, depending on timing. Should not be
               a problem as it only happens during idle and resume (and possibly at startup).
            2: When it needs to adjust the volume and the volume control is not started, it will start it causing
               the current active application to loose focus for a second. I give focus back almost instantly though.

            Changes to Settings.ini requires a restart.

Compability: Tested on Windows 7 x64 and Windows 8.1 x64. Might work on Vista. It should work on XP, but only to
             totally mute. No fading of the volume is possible. Set Simply_Mute_Audio=True if testing on XP.

Changes: 1.0 - 2014-12-15 - First public release.
         1.1 - 2014-12-16 - Should now be better to work with the volume as it can detect current volume and set
                            absolute values to it. Only works on Windows 7 or better now though. Perhaps Vista.
                            If you set it to Simply_Mute_Audio=True, it might work in XP. Not tested.

                            You can now abort the volume fading out when going idle by clicking any key or moving
                            the mouse. 

                            Smoother fade. 1.0 moved the volume 2% at a time. This moves it 1% at a time.

                            Volume can now be set to a percent of current volume, leaving you free to modify the
                            volume at will manually.

                            Changed settings are
                            Add: Set_Volume_at_Idle_to_Percent. Will set the volume to a percent of current volume.
                            Chg: ForceMuteOff. Only worked if Simply_Mute_Audio was True. Now also used if 
                                 Set_Volume_at_Startup is set to False.
                            Chg: Set_Volume_at_Idle. It is now always the value you set it to.
                            Add: QuitKey added. This lets you set your own key to exit the application.
                            Del: ExitWithShiftESC option removed because of the above.
                            Add: ExitWithQuitKey added. If you do not want to quit with the QuitKey, set this to False.
                            Del: KeyPressDelay option removed. No longer used.
                            Add: LoopDelay added.
                            Chg: FadeOut_Delay and FadeIn_Delay can now be set to "False" to instantly change volume
                                 without fading.

         1.2 - 2014-12-17 - Add: [IdleException] added to config. See Readme for explanation. Makes it possible
                                 to skip going idle when, for example, starting a movie or something. Defined by process.

                            Add: MaxDelayIfExceptionFound added to be able to force how long it should wait for the 
                                 excluded process to close if its running. It will then try again. Default is 0 for 
                                 indefinate and you should never have to touch it really, unless it does not resume 
                                 as it should when all the excluded processes closes.

                            Add: Name and version of the program will now be in its tooltip when hovering over it.
                                 It will also show the status (waiting for idle, currently idle, waiting for excluded
                                 process to close etc).

         1.3 - 2014-12-18 - Add: Added the [IdleSplash] section to be able to show a moving message or image on screen
                                 when the volume is muted/faded.

                            Add: Added a check so that only one occurance can be running at a time.

                            Add/Chg: Added VolumeMixerName in [Advanced] where you specify the name of the Volume Mixer window.
                                     It did not work at all if it did not start with "Volume Mixer" before (language dependent).
                                     It will help set this up the first time your run this version.

                            Del: MaxDelayIfExceptionFound removed. There are no max delay anymore as it was not really needed.

Settings:

[General Settings]

Time_To_Idle=
Number of seconds before being considered idle. Any keypress or mousemove should reset this timer.
Valid: Any number of seconds.
Default: 360

Debug=
When this is enabled, a traytip will be used to describe what it is doing. If you run into problems or are
interested in what the options you set modify how it works, set this to True.
It will also show the volume control when changing volume.
Note: There are a few more sleep functions while in debug mode to be able to see the messages so it might feel
      a bit sluggish when debug is on. Its detects keypresses and similar faster with debug off.
Valid: True/False
Default: True


[Sounds Options]

Simply_Mute_Audio=
When this is enabled, audio will simply be muted when the idle time kicks in. No fading will occur or similar
just mute or unmute instantly.
When this is enabled, all other options in [Sound Options] are non-valid and do nothing.
Valid: True/False
Default: False

Set_Volume_at_Startup=
Set this volume, in percent, when starting the program. This ensures that the volume is always at the defined level when this
app starts and resuming from idle. Set to False to disable this function.

If set, it should be set higher then "Set_Volume_at_Idle" below, but should work anyway. In fact, if you set it
lower then Set_Volume_at_Idle, this program will work in reverse (Increase volume when idle)!

If this is set to False, your volume is not touched at startup. When recovering from idle mode though, it will go
back to the volume it had before going idle.

Valid: False/0-100  - where 0 is lowest and 100 is max volume.
Default: False

Set_Volume_at_Idle_to_Percent=
Lower the volume by this Percent when going idle. If this is set to 50 and your volume, when going idle, is 80%, your volume
will be set to 40% (50% of 80 is 40).
If you set Set_Volume_at_Startup to False (Do not enforce a volume at startup), you are free to change the volume as you want
and it will always recalculate the percentage when its time to idle.

Valid: False/1-99
Default: 20
Requirement: Set_Volume_at_Idle=False

Set_Volume_at_Idle=
Set this volume when going idle. If you set this to 20, your idle volume will always be 20%, no matter what the normal
volume was. Both this and Set_Volume_at_Idle_to_Percent can not be set at the same time. Set one of them to False.

Valid: 0-100
Default: False
Requirement: Set_Volume_at_Idle_to_Percent=False

FadeOut_Delay=
The delay when fading out. This setting defines how fast the volume is lowered in milliseconds between each
percent of "Volume down".
While 0 delay is quite fast, you can also set it to "False" to instantly change the volume.

NOTE: You CAN abort the fade out process and raise the volume back up by clicking any key or moving the mouse.

Valid: False/0-10000
Default: 450

FadeIn_Delay=
Same as above, but how fast to raise the volume again when you are no longer idle.
Valid: False/0-10000
Default: 20


[IdleException]

This section is only used to define processes that should pause the idle process.
You specify one Exception<#>= per line (basically the .exe file).
Do not remove them all. To disabled, set Exception1=NONE
If it finds one of the processes defined here as running, it will pause for 5 seconds before checking
again. Debug=True is good when testing this function as it spells out when its pausing.
You can add as many Exception<#> as you want.

Example:
Exception1=notepad.exe
Exception2=calc.exe
Exception3=somethingelse.exe

Valid: Exception<#> entries.
Default: 
Exception1=NONE


[IdleSplash]

This function has two settings. It either shows an image or text. Lets call the modes Image or Text mode from now on.
To enable image mode, put one or two .jpg images in the same folder as the application.
muting.jpg = Shown when the volume is fading down.
muted.jpg = Shows when the volume is faded/muted. This one moves around.

EnableIdleFlash=
Enable the Flash/Splash system. This will enable this function.
Settings this to False disables all other values in [IdleSplash].
Valid: True/False
Default: True

IdleFlashText=
The text to show when it its idle in text mode. To enable Image mode instead, put a muted.jpg file in the 
same folder as the program itself. To enable Text mode again, rename or remove muted.jpg
Valid: Any text. No quotes needed.
Default: Volume faded. Press any key to resume

IdleFlashTextWinSizeW=
IdleFlashTextWinSizeH=
The width and height of the window showing the IdleFlashText or Image. If you are using an image, it should be
the resolution of the image itself (check properties on it). In Text mode, it also controls the size
of the window.
Valid: Pixels
Default: 400, 291 (for the "muted.jpg" image that comes with the program. If you use the default text, 
         set it to 400, 42.)

IdleFlashTextDuring=
While the audio is fading out, this message is showing, in Text mode. To enable image mode instead 
put a muting.jpg image file in the same folder as the progam itself.
Will be replaced by IdleFlashText when fading is complete.
Valid: Any text. No quotes needed.
Default: Volume is fading. Press any key to abort

IdleFlashTextWinSizeDuringW=
IdleFlashTextWinSizeDuringH=
The width and height of the above window. In Image mode, it should match the size of muting.jpg.
Valid: Pixels
Default: 170, 170 (for the "muting.jpg" image that comes with the program. 400, 42 for the default text.

IdleFlashLoopsToMove=
The IdleFlashText can jump around on screen, like a screensaver. How many loops of the program do you want to wait before it moves?
The default looptime is 1 second (Controlled by LoopDelay in [Advanced]), so setting this to 5 means that it will wait 5
seconds before moving the window.
Valid=0-infinite. Set 0 to keep the flash centered.
Default: 1

IdleFlashTextFontName=
The name of the font to use. Set "default" to use the system font. This is only used in Text mode.
Valid: Any (?!) installed font name. No quotes needed. When looking at your fonts, select properties on the one you want. Check the
       "Title" name. That is the name to use.
Default: default

IdleFlashTextFontSize=
The size of the font. default is 12. This is only used in Text mode.
Valid: 6 8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72
Default: default

IdleFlashTextFontWeight=
The weight of the font from 1-900. This is only used in Text mode.
Normal is 400 so under it will make the font thinner. Over 400 will make it bolder.
Valid: 0-900 where 0 is the default weight for the selected font.
Default: default

IdleFlashDebug=
Set this to True if you want to test your flashes. It will switch between them every 4 seconds, showing your result.
Exit the program to quit the demo.
Valid: True/False
Default: False



[Advanced]
Advanced settings in here. Should not need to use them really.

ForceMuteOff=
Only used if Simply_Mute_Audio is set to True or Set_Volume_at_Startup is set to False. If this setting is True, it 
will ensure that mute is not on when starting the program by lowering the volume one step and raising it once again.
Otherwise, if mute is on when you start the program and when idle time kicks in, it can get confused.
Valid: True/False
Default: True

QuitKey=
The key to use to quit the program. The default is +{ESC} which means Shift-ESC.
You can read this page for usage: https://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm
This must be set, so if you do not want a QuitKey, use ExitWithQuitKey below to disable it.
Valid: Any Autoit3 key from URL above.
Default: +{ESC}

ExitWithQuitKey=
If you do not want to quit the program with a keypress, set this to False. That disables the QuitKey.
Valid: True/False
Default: True

AbortIdleUsingFadeIn_Delay=
If you abort the fade out process when its lowering the volume, do you want to instantly
raise the volume back up or fade it back in using the FadeIn_Delay value?
Valid: True/False
Default: True

MaxDelayIfExceptionFound=
Maximum amount of time, in seconds, to wait for an excepted process to close before trying again.
You should only even have to touch this if you are having problems with it not detecting that the
excluded process (Exception) has closed. If so, try setting it to 10 (or something) seconds.
Valid=0-10000 seconds, where 0 is wait indefinetly.
Default: 0

LoopDelay=
This program is basically one big loop where it checks idle time and volume. The default is 1000 ms meaning that 
it does its thing every second. If you want it to be more responsive, you can lower this value. If it eats all
your CPU (no, it wont), you can raise it.
Be careful with this option. Setting it to low will most likely cause problems. Setting it too high will cause
it to miss when you are no longer idle.
Valid: 0-infinte (Do not set 0 though).
Default: 1000 (one second).

VolumeMixerName=
What is the Volume Mixer called? The first time you run this program, when it sets up the Settings.ini, it will
try to detect it and autoset it for you.
It matches from the start of the text, so if your Volume Mixer window is called
"Volume Mixer - Speakers (2- Realtek High Definition Audio)"
it is enough if you just define it as
"Volume mixer - Speakers".
Try to be as precise as you can though, so it does not start manipulating the volume in the wrong window.

You can also set it to AUTO (case sensitive). It will then try to autodetect it every start, but since this is timing
dependent, it is better to have it hardcoded.

Valid: AUTO / The name of your Volume Mixer window.
Default: None. It will be autodetected at first startup.
