Author Topic: One button action?  (Read 2192 times)

Cloak187

  • Guest
One button action?
« on: October 16, 2017, 02:18:45 AM »
How do I use the same key to turn down and turn up the volume?

 For example if I wanted to use the "A" key to adjust the volume to 20% and then use the same key to toggle the volume back up to 50% whenever I push the key again.

I've already figured out how to add the command to make it go down to 20% using the "A" key but I don't know how to make it execute turning it back up to 50% using the "A" Key. Is it even possible?

Thanks in advance!  ;)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: One button action?
« Reply #1 on: October 16, 2017, 09:44:28 AM »
If you're looking to change the global system volume, you can use the "{STATE_SYSVOL}" token to get the current level:
Code: [Select]
Begin Text Compare : [{STATE_SYSVOL}] Equals '20'
    Set system audio volume to [50]
Else
    Set system audio volume to [20]
End Condition

This will toggle between the two states.
Note that this checks the exact value, which is why it checks for 20; If the volume is not currently 20, it will make it 20. I.E. it defaults to the lower setting to prevent going too loud.


You can also convert the token to an integer so you can use non-exact values(In case you're also adjusting the volume manually, so it wouldn't just be those two values):
Code: [Select]
Set integer [STATE_SYSVOL] value to the converted value of {STATE_SYSVOL}
Begin Integer Compare : [STATE_SYSVOL] Is Greater Than 35
    Set system audio volume to [20]
Else
    Set system audio volume to [50]
End Condition