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.

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


[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).
