Tur-Another Idle Volume Adjuster by Turranius

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

First hints: You do not really need to go through all the settings in this file. Start the program and accept the default settings to get
             a feel for it. If you THEN want to tinker, you can read through this document before editing Settings.ini

Features: * Set the volume to a percent of the current volume after an amount of time (This is the default).
          * Just mute the audio after an amount of time (Should work for XP)
          * Force the volume to a certain percent at startup.
          * Force the volume to a certain percent when going idle (A definable percent instead of a percent of current volume).
          * Definable FadeOut delay and FadeIn delay.
          * Exceptions. You specify the exe file(s) you want. If one of them is active, it will not go idle.
          * Volume per program. has the ability to change the volume to a certain percent if a process (program) is running.
          * Splashscreen. By default, a progress bar is shown. You can also use images (included examples) that are shown when going idle and when it is idle. Or use message boxes instead. Or disable the splashscreen.
          * Right click it in the traybar for a menu.
          * And a few advanced options.

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 it should work for anything really.

Usage  : You only need the exe file. The first time you run it, it will create:
         * The Settings.ini file with default values.
	 * muted.jpg & muting.jpg. Default splashscreen images if you want them.
         * W7VVol.dll - This is the file that controls the volume. It will be recreated if you delete it.
         * Tur-Another Idle Volume Adjuster.log - The logfile. The default loglevel is 1 (info).
         * If you ever right click its icon in the traybar and select "Read/Follow logfile", then
           cmtrace.exe will be extracted as well and used to load the logfile.

         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.

Compability: Tested on Windows 10 x64, 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 running on XP.

Thanks: Thanks to Dime333 for being patient and testing it. My biggest supporter =)

Settings:

[General Settings]

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

LogLevel=
Set level of logging to "Tur-Another Idle Volume Adjuster.log".
0: Logging disabled.
1: Informational logging only.
2: Debug logging.
3: Debug2 logging. Will spam a lot, showing idle time etc.
Valid:0-3
Default: 1


[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. This should make it possible to run on XP.
When this is enabled, all other options in [Sound Options] are not 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, it will then 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.
NOTE2: The default is to move the volume 1% at a time for a nice fade. However, for those that really want to
speed it up, setting it to 0-9 will move the volume 7 steps at a time. 10-19 is 5 steps. 20-29 is 3 steps.

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.

NOTE: If you are using Pause (Previously HyperPause) a lot, you may want to set this to False. 
If you enter Pause while the volume is faded out, the volume will be faded out again when you exit Pause, but TAIVA does not think its idle.
This is a feature of Pause. "Check what the volume is when entering Pause, restore it to that level on exit".
NOTE2: The default is to move the volume 1% at a time for a nice fade. However, for those that really want to
speed it up, setting it to 0-9 will move the volume 7 steps at a time. 10-19 is 5 steps. 20-29 is 3 steps.

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).
If it finds one of the processes defined here as running, it will pause until its gone.
You can add as many Exception<#> as you want.

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

Valid: Exception<#> entries. You can either have the first exception set to NONE or delete it to disable.
Default: Empty (disabled).


[ProgramSpecificVolume]

This section defines one or more processes to check if they are running. If one of them are running it will set
the volume to that which is defined for that process. It will not fade though. Just "boom - new volume".
Leave it empty to disable (Do not leave crap in here as it has to check all processes each "loop" so it will
take a little more resources to have lots of programs in here).

Example:
calc.exe=50
notepad.exe=30
That will set the volume to 50% if calc.exe is running and 30% if notepad is running.
If both programs are running at the same time, the first hit will be the dominating program it sets the volume to.
Also check the advanced setting "ProgramSpecificVolumeIfActiveOnly" below as it decides how this function works.

Valid: processes=volume_to_set. Leave it empty to disable.
Default: Empty (disabled).


[IdleSplash]

This function has two settings (well, three with IdleFlashProgressBar below). 
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.

Please note, some emulators does not allow the image to be shown. It works fine in HyperSpin and MAME for example, but
not in Daphne. It wont break anything, just not show the IdleSplash in those emulators.

EnableIdleFlash=
Enable the Flash/Splash system. This will enable this function.
Settings this to False disables all other values in [IdleSplash] and no indication will be given when going idle.
Valid: True/False
Default: True

IdleFlashTransparency=
Sets the transparency of the different splash windows. Range is 0-255 where 0 is fully transparent (invisible) and 255 is
not transparent at all. Set 255 to disable transparency. Setting 0 is useless. Might just as well set EnableIdleFlash=False.
Valid: 0-255
Default: 150

IdleFlashProgressBar=
With this enabled, the current volume will be shown in a progress bar when the volume fades out or in. It has multiple options.
Any setting other then "False" will override the "muting.jpg" image. That will not be shown if its not False.
False		= Disabled. Show "muting.jpg" if it exists, otherwise show IdleFlashTextDuring text box.
True		= Show the volume when fading out or in.
FadeOutOnly	= Show the volume when fading out only.
FadeInOnly	= Show the volume when fading in only.
Valid: True/False/FadeOutOnly/FadeInOnly
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.
This is not used when IdleFlashProgressBar is set to anything other then False.
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 (or image) can move 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 it centered at all time.
Default: 1

IdleFlashAllScreens=
When set to True, the IdleFlashText or image will move across all screens, if you have them.
When set to False, it will only move around on the primary screen.
Valid=True/False
Default: True

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


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

ProgramSpecificVolumeIfActiveOnly=
This controls how [ProgramSpecificVolume] works. If you have no program specific settings, it has no effect.
With it set to False, if the process is running, the volume will be set with the first "hit" winning. Example:
[ProgramSpecificVolume]
notepad.exe=100
Firefox.exe=50
With this option set to false, the first program to start (notepad or firefox) will set the volume to that.
If a volume is set for a particular program, it will not set another volume until the first one is closed.

If it is set to True however, the process must be running AND being the active window. If it is not the active window
then the volume will not be set. An example could be to set HyperSpin.exe=100 in the [ProgramSpecificVolume] list and
set this option to True. It will then always set the volume to 100% as soon as HyperSpin.exe is the active window.

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
To disable it, leave it empty or set it to False
Valid: False / Any Autoit3 key from URL above.
Default: +{ESC}

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

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. Actually, dont touch it at all.
Valid: 0-infinte (Do not set 0 though).
Default: 1000 (one second).

ForceDelay=
This is the number of seconds to wait, when loaded, before doing anything basically. In some cases, you might
want to wait before TAIVA activates itself.
Valid:0-infinite.
Default: 0 (Disabled)

ShowHiddenSndVolKey=
This is a keycombination to run or kill the Volume Mixer. Might be useful to have a shortcut to it IMO.
Valid: Any command acceptable. See QuitKey above. Same as with that one.
Set it empty or to False to disable the key combination.
Default: +!v (meaning Shift-Alt-V)

FadeOutNowKey=
This is the keycombination that forces TAIVA to fade out volume NOW instead of waiting for the idle timer.
It is the same function as if you right click the TAIVA icon in the traybar and selecting "Fade out now".
Valid: Any command acceptable. See QuitKey above. Same as with that one.
Set it empty or to False to disable the key combination.
Default: +!f (meaning Shift-Alt-F)

ManualVolumeUp=
This key raises the volume one step. Please note that each notch is 2%.
Valid: Any command acceptable. See QuitKey above. Same as with that one. Leave it empty to disable.
Default: !{UP} (meaning Alt-Up)

ManualVolumeDn=
This key lowers the volume one step. Please note that each notch is 2%.
Valid: Any command acceptable. See QuitKey above. Same as with that one. Leave it empty to disable.
Default: !{DOWN} (meaning Alt-Down)

ManualVolumeStep=
How many steps do you want to raise or lower the volume for each click?
Note that each step is 2% so setting this to 5 raises or lowers the volume by 10%.
Valid:1-50
Default: 5 (10%)

ManualVolumeAutoSave=
With this set to True, it will automatically save the new volume set to ProgramSpecificVolume for that process. That means that it will remember
the volume you set with ManualVolumeUp and ManualVolumeDn for the next time this process is started.
Valid: True/False
Default: False

ManualVolumeAutoAdd=
When this is set to True and you use ManualVolumeUp or ManualVolumeDn and the current process is NOT in the ProgramSpecificVolume settings, it will
automatically be added to it. A question will pop up, asking you if you are sure and show you the process it will add.
If you do not say "Yes" to that question, nothing will be added. This question only pops up once, since after you say "Yes", it will be added
to the ProgramSpecificVolume settings and the normal procedure will follow (always save new volume).
If you set this to AUTO, the active process when you use ManualVolumeUp or ManualVolumeDn will always be saved. No questions asked (dangerous).
Requires: ManualVolumeAutoSave=True
Valid: True/False/AUTO
Default: False