rkayd
January 10, 2023, 4:04pm
1
I want to get the current volume settings then mute the volume.
After I am done with the app I want to reset the volume to the original setting.
Is there a way to get the current volume in Keyboard Maestro (similar to getting the current mouse position)?
I seem to be able to do this with AppleScript but I can't figure out how to save that value to a KM variable to use later.
tiffle
January 10, 2023, 4:13pm
2
I remember posting about this some time ago. Since I'm away from my Mac I'll refer you to the discussion:
It is possible to achieve what you want using KM. Here is a macro I use to set system volume. It is interactive, which is not what you want, but you can re-use the two Execute AppleScript actions (coloured green) in a macro of your own (which will be a good learning experience) to do what you want. The first green action gets the current volume level while the second green actions sets the new level.
I don't have time to create a new macro for you, but I hope you can use this information as a sā¦
It works on Mojave so YMMV but it demonstrates saving to KM variables...
Be sure you scroll down to Post #5 to see how to handle local and instance variables.
Also ā keep in mind that you can set an AppleScript action to save the AppleScript result to a variable.
rkayd
January 10, 2023, 6:35pm
4
Thank you. The first part worked great out of the box but I was having trouble resetting the volume. After playing around a bit I found that removing the set vol as integer worked as I want it. I'm not sure why that is but I suppose since I am not changing the value it doesn't need to be converted to an integer anyway.