Volume Control Slider
- JoeWinograd
- Posts: 2179
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Volume Control Slider
Just modified the script in my previous post to make the bar width one-third the screen width, thereby avoiding another hard-coded value. The only hard-coded value now is the bar height. Also, fixed the missing X and Y on the Gui,Show, and added some Round calls. Regards, Joe
Re: Volume Control Slider
Hi Joe, registered just to thank you. This is brilliant, exactly what i neededJoeWinograd wrote: ↑20 Feb 2022, 14:08Our posts crossed.jrachr wrote:colors to be different as volume goes up(maybe green) and volume down(Maybe red)
That's an interesting idea. Below is a revision of the script with three changes:
(1) Bar-centering and width based on screen width and height.
(2) Automatically unmuting whenever you increase or decrease the volume.
(3) When you increase the volume, the bar is the color in the BarColorIncreasing variable (set to Green in code below). When you decrease the volume, the bar is the color in the BarColorDecreasing variable (set to Red in code below).
Regards, Joe
Code: Select all
; Joe Winograd 20-Feb-2022 ; Developed for Windows 10, but tested successfully on W7, W8.1, W10, W11 (all 64-bit) ; Updated with Toggle Mute feature 10-Mar-2021 ; Updated with Red and Green sliders for Muted and Unmuted states 10-Mar-2021 ; Updated 20-Feb-2022: ; Red and Green sliders when decreasing and increasing volume (no longer for muted/unmuted) ; Automatically unmuting when decreasing and increasing volume ; X coordinate and bar width based on screen width ; Y coordinate based on screen height #Warn,UseUnsetLocal #NoEnv #SingleInstance force SetBatchLines,-1 ; begin values to change BarHeight:=20 BarWidth:=Round(A_ScreenWidth/3) BarXlocation:=Round((A_ScreenWidth-BarWidth)/2) BarYlocation:=Round((A_ScreenHeight-BarHeight)/2) BarColorDecreasing:="Red" BarColorIncreasing:="Green" BarMillisecondsToStayOnScreen:=3000 ; 3 seconds ;HotkeyVolumeDown:="!Left" ;HotkeyVolumeUp:="!Right" ;HotkeyToggleMute:="!^m" HotkeyVolumeDown:="NumpadSub" HotkeyVolumeUp:="NumpadAdd" HotkeyToggleMute:="NumpadMult" ;VolumeIncrement:=1 VolumeIncrement:=10 ; end values to change SplitPath,A_ScriptName,,,,ProgramName Hotkey,%HotkeyVolumeDown%,VolumeDown Hotkey,%HotkeyVolumeUp%,VolumeUp Hotkey,%HotkeyToggleMute%,ToggleMute SoundGet,Volume Volume:=Round(Volume) TrayTip:=HotkeyVolumeDown . " or " . HotkeyVolumeUp . " to adjust volume" . "`n" . HotkeyToggleMute . " to toggle mute" . "`nCurrent Volume=" . Volume TrayIconFile:=A_WinDir . "\System32\shell32.dll" ; get tray icon from shell32.dll TrayIconNum:="-225" ; use music note as tray icon (icon 225 in shell32) Menu,Tray,Tip,%TrayTip% Menu,Tray,Icon,%TrayIconFile%,%TrayIconNum% Gui,+ToolWindow -SysMenu Gui,Add,Progress,w%BarWidth% h%BarHeight% c%BarColor% vBarVal Gui,Hide Return ; end auto-execute VolumeDown: SoundSet,0,,Mute ; unmute BarColor:=BarColorDecreasing SetTimer,SliderOff,%BarMillisecondsToStayOnScreen% SoundSet,-%VolumeIncrement% Gosub,DisplaySlider Return VolumeUp: SoundSet,0,,Mute ; unmute BarColor:=BarColorIncreasing SetTimer,SliderOff,%BarMillisecondsToStayOnScreen% SoundSet,+%VolumeIncrement% Gosub,DisplaySlider Return ToggleMute: SoundSet,+1,,Mute ; toggle the mute setting Return SliderOff: Gui,Hide Return DisplaySlider: SoundGet,Volume Volume:=Round(Volume) Title:=ProgramName . " Current Volume=" . Volume Gui,Show,x%BarXlocation% y%BarYlocation%,%Title% GuiControl,,BarVal,%Volume% GuiControl,+c%BarColor%,BarVal TrayTip:=HotkeyVolumeDown . " or " . HotkeyVolumeUp . " to adjust volume" . "`n" . HotkeyToggleMute . " to toggle mute" . "`nCurrent Volume=" . Volume Menu,Tray,Tip,%TrayTip% Return
- JoeWinograd
- Posts: 2179
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Volume Control Slider
Hi weeuweed,weeuweed wrote:registered just to thank you
You're welcome, and thanks back to you for taking the time to register just to thank me...I really appreciate that! I'm glad the script is what you need. Regards, Joe
- JoeWinograd
- Posts: 2179
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Volume Control Slider
For anyone using the script above, I just fixed a bug in it where the timer was not turned off when the slider was turned off. Regards, Joe
Re: Volume Control Slider
@Joe Thank you very much for the update Joe.Sorry for late response.Had no power or internet because of hurricane up here.Thanks again.
- JoeWinograd
- Posts: 2179
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Volume Control Slider
Hi Jr,
I saw that the hurricane went up your way. I hope you and your family came out of it well. Regards, Joe
I saw that the hurricane went up your way. I hope you and your family came out of it well. Regards, Joe
Re: Volume Control Slider
@Joe. Other than no power for a couple of days and no cable or internet we did ok.Lol.You don't realize how naked you are until you have no internet. Just wrong.But all good now. Tk's for asking.
Re: Volume Control Slider
@jrachr glad it's all over ... here some links , weather / hurricane
viewtopic.php?f=17&t=52&p=484580#p484580
viewtopic.php?f=17&t=52&p=484580#p484580
Re: Volume Control Slider
Hi @JoeWinograd
Thank you so much for your script. I have it working on my end.
But it begs the question, how do I include a microphone mute hotkey in the script?
Yes, it mutes my speakers. But can we also apply this script for day to day meetings (microphone control) for example?
Thank you so much for your script. I have it working on my end.
But it begs the question, how do I include a microphone mute hotkey in the script?
Yes, it mutes my speakers. But can we also apply this script for day to day meetings (microphone control) for example?
Last edited by nelvin08 on 19 Feb 2023, 01:24, edited 1 time in total.
- JoeWinograd
- Posts: 2179
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Volume Control Slider
Glad to hear it!nelvin08 wrote:I have it working on my end.
Here's a forum thread on that (and a search for "microphone mute" will get others):nelvin08 wrote:microphone mute
viewtopic.php?f=6&t=15509
I've made no attempt to integrate that (or any mic-mute code) with my volume control script, but it should be doable. Regards, Joe
Re: Volume Control Slider
I swear I tried this one earlier and it didn't work.
Maybe I was getting the wrong ID then. All good now.
I was actually playing with it and since the SoundSet only works for only 1 device (I assume), I tried the below code so whatever mic I am using (since I might be switching from time to time), it mutes and unmutes both.
There's no harm in doing this right?
Maybe I was getting the wrong ID then. All good now.
I was actually playing with it and since the SoundSet only works for only 1 device (I assume), I tried the below code so whatever mic I am using (since I might be switching from time to time), it mutes and unmutes both.
There's no harm in doing this right?
Code: Select all
!`::
SoundSet, +1, MASTER, Mute, 16
SoundSet, +1, MASTER, Mute, 19
return