Tur-Another Idle Volume Adjuster by Turranius

Original 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.
             Start with what you can find in the configuration GUI by right clicking the tray icon.

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 (Works on 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.
          * Launch other applications, in a specific order, with a definable delay.
          * 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 works 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.
         * 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.

         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. Should work on Vista. It works on XP, but only to
             totally mute. No fading of the volume is possible. Set Simply_Mute_Audio=True if running on XP.

Limitations: Thanks to Microsofts infinite wisdom, moving or pressing on a game controller does not reset the "how long have the user
             been idle" timer, which is what this program uses. Your volume might therefor be lowered if you are playing only with a 
             game controller. This is rather individual and might not happen to you though. It depends on Windows version and patch level.

Extras:      In the Extras folder, you can run Test_Idle_Time.exe. It will display the time the system has been idle and should reset itself
             if you move or do anything. If you find that TAIVA never goes idle, run it and make sure it rises when you do not touch anything.
             If it keeps resettings, you have some device that resets the Windows idle time. Unplug devices (probably a keyboard or controller) until
             you find the culprit.

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 True, audio will simply be muted when the idle time kicks in. No fading will occur or similar
just mute or unmute instantly. This makes 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 (0-100) 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.
Please note: If your system is muted at startup, the volume will still be set but the mute is not touched.

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 as it will be shown behind the game.

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

IdleFlashProgressBarWidth=
This controls the width in pixels of the IdleFlashProgressBar.
Default: 665

IdleFlashProgressBarHeight=
This controls the Height in pixels of the IdleFlashProgressBar.
Default: 19

IdleFlashProgressBarLeft=
How many pixels from the left should the IdleFlashProgressBar appear? Set -1 for the center of the screen.
Default: -1

IdleFlashProgressBarTop=
How many pixels from the top should the IdleFlashProgressBar appear? Set -1 for the center of the screen.
Default: -1

IdleFlashProgressBarVertical=
Set this to True if you want a vertical volume bar instead of the default horizontal one.
Note that if changing this, you should switch the IdleFlashProgressBarWidth and IdleFlashProgressBarHeight 
values around of course.
Default: False

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



[Manual Volume]
Here are settings that concern the manual Volume Up and Dn functions.

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

ManualVolumeUseAPI=
Normally, when manually changing the volume up and down, we use the Windows API for that. If you'd rather use the alternate method to do that
set this to False. It will then use the internal system to raise and lower volume. When False, there is a good chance that the volume will be
displayed on screen by your sound drivers. Some people prefer to show that. Matter of taste.
Valid: True/False
Default: False

ManualVolumeShowProgressBar=
When changing the volume, a volume "progress bar" will be shown with the current volume. This is the number of seconds to show this volume bar.
Set it to False to disable it. If you want it to blink really fast, set it to 0.3 or similar although it will "slide" nicely when volume goes
up and you'll miss that if you set it to quick. 2 seconds is recommended minumum.
If you use ManualVolumeUseAPI=False above, you might want to set this one to False too so you do not get two volume bars. Try it out.
NOTE: This is the same volume bar as when fading in our and out when you have IdleFlashProgressBar=True, so you can control the look its using:
IdleFlashProgressBarWidth=
IdleFlashProgressBarHeight=
IdleFlashProgressBarLeft=
IdleFlashProgressBarTop=
IdleFlashProgressBarVertical=
Valid: False/0.1-10
Default: 2



[Advanced]
Advanced settings in here. 

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 be 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

IdleExceptionIfActiveOnly=
This controls how [IdleException] works in the same way as ProgramSpecificVolumeIfActiveOnly.
False = The process must be running somewhere for TAIVA to go idle and wait for it to close.
True = The process must be running and its window must be the active one for TAIVA to go idle.
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

RestoreVolumeOnExit=
If its in idle mode when you shutdown your system or exit TAIVA, do you want it to try and restore the volume first?
Instant = Instantly restore the volume.
Fade = Fades the volume back in with a forced FadeIn Delay of 20 (Quickly).
Disabled = Do not force the volume back. If you have Set_Volume_at_Startup set, its fine to leave it at Disabled since
it will be restored the next bootup anyway.
Valid: Instant/Fade/Disabled
Default: Fade

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

ForceFocusSetup=
This function is not added by default to the Settings.ini file. If you want to use it, you have to add it manually
in the [Advanced] section.
It allows you to hold two keys for a number of seconds to force a window/program into focus. It was created to force
HyperSpin back into focus if it got lost somehow, but can be used for any window that has a title really. Kind of like an emergency key.
It requires 4 settings, separated by |.
Key1|Key2|Seconds|WindowsTitle

In the Extras folder, read the KeyList for ForceFocusSetup.txt file to see the keyvalues to use for Key1 and Key2.
Example: ForceFocusSetup=0x12|0x24|2|HyperSpin
That means, if you hold ALT and HOME for 2 seconds, it will force focus back to a window titled "HyperSpin".

Default: Not set at all. Might cause more problems then its worth so..

[ProgramLaunch]
Below this, you can add applications you want launched after TAIVA has started and is ready for action.
In some cases, you might want to launch an application here, after TAIVA is done, instead of using another start script.
For example, if you have Unmute_at_Startup=True, then TAIVA will press VolumeUp and VolumeDown once at startup to 
ensure that mute is off. This counts as a keypress so if HyperSpin, for example, is running its intro animation, it will be aborted since it
thinks you pressed a button. You can then use this function to launch HyperSpin from here instead, ensuring that it has already all it needs to
before HyperSpin starts.
The syntax is: <Exe To Run>=<Working Dir>=<Seconds before starting>
Example:
HyperSpin.exe=I:\Arcade\HyperSpin=2
That will run I:\Arcade\HyperSpin\HyperSpin.exe with a workingdir of I:\Arcade\HyperSpin in 2 seconds after TAIVA is done with its initialization.
If you do not want to specify a workingdir, specify full path to the exe instead and leave the <Working Dir> empty.
Example:
C:\Windows\System32\Notepad.exe==0

You can use a delay of 0 to run it as fast as possible.
The programs will be launched in the order defined.

Example:
[ProgramLaunch]
HyperSpin.exe=I:\Arcade\HyperSpin=0
C:\Windows\System32\NotePad.exe==10

That will run HyperSpin as soon as possible, then wait 10 seconds and launch Notepad.
