Author: Sander
Script Version: 1
Minimum CoyoteMIDI Build: 553
// if the configured hotkey for ignoring the input trigger is pressed
if ($parameters IgnoreKey) && (keystate ($parameters IgnoreKey))
return
// Figure out if the max MIDI value for this event is 127 or 16383 (pitchbend)
$max = 127
if ($trigger midievent) == pitchbend
$max = 16383
// convert the 0-127 or 0-16383 scale from the MIDI event to a 0-100 scale for setvolume
$volume = (round ($trigger rawvalue) / $max * 100)
// if 'foreground' is specified as target, or the configured hotkey for the foreground is pressed
if ($parameters Target) == foreground || (($parameters ForegroundKey) && (keystate ($parameters ForegroundKey)))
$target = (getfocusedprocess)
// if the translation parameters specify a target, use that instead
else if ($parameters Target) && ($parameters Target) != "*"
$target = ($parameters Target)
// change the volume of the target
setvolume $volume $target
// on Windows, update the mute state of the target, if necessary
// (on MacOS, polling the mute state this frequently is currently too CPU intense to be worth it)
if (platform) == Windows
if $volume < 3 && !(getmute $target)
setmute true $target
if $volume >= 3 && (getmute $target)
setmute false $target
// indicate the volume level on the logo indicator across a range from green to red.
indicator true (R: $volume * 5.11,G: 5.11 * (100 - $volume), B: 0) 1
// define the parameters to be displayed in a translation.
event uirefreshed
if (platform) == Windows
translationparameter Target (textbox "Target" "The process to change the volume of. A blank value or '*' will target the system volume. 'foreground' will target the foreground application.''" "*")
translationparameter ForegroundKey (textbox "Foreground Key" "The key to press down when the script should modify the volume of the foreground app instead of the target." CTRL 0.3)
translationparameter IgnoreKey (textbox "Ignore key" "The key to press down for when the script should do nothing while the MIDI input is triggered." SHIFT 0.3)
25 downloads