Volume Control on PC Windows 10

Ask gaming related questions (AHK v1.1 and older)
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Volume Control on PC Windows 10

22 Apr 2018, 10:40

Hi. First, I’m new here on this website & with never using AutoHot keys before. Therefore, please excuse me I I’m posting my post/question under the incorrect category within this forum. My inquiry strictly pertains to my PC/laptop (Windows 10). Second, please also understand that I’m physically disabled (a quadriplegic), I type with a head stick/pointer, & cannot maneuver the cursor via a mouse. Instead, I maneuver the cursor by mouse keys (the numeric key pad.) I would like to know if & how I can create a script (Hot Keys) to access the Windows 10 horizonal (slider) volume control (within the Icon try) Then, I might be able to use my left/right directional arrow keys to decrease/decrease the volume.

2-things: 1) I do have a short key to decrease/increase the volume control, but what comes up is the old Windows XP vertical hour-glass. Here, I use the up/down directional keys to increase/decrease (control) the volume. Whereas, (as I stated) I much prefer that if there’s a way I can create a shortcut key (maybe through using AutoHot Keys/commands) to access the Windows 10 horizonal (slider) volume control. I know there’s an AutoHot Key script for volume control involving moving the wheel on a mouse. But, again I don’t use a mouse so are there any other alternatives?

Any advice/suggestion would be greatly appreciated! Thanks in advance! :)
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Volume Control on PC Windows 10

22 Apr 2018, 14:17

Code: Select all

Left::SoundSet, -5
Right::SoundSet, +5
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

23 Apr 2018, 09:59

Hi swagfag! Thanks for responding to my post! As I said, I'm brand new with using AutoHotKeys nor I'm good with coding.
If possible,can you elaborate some more on where to put in this code & what to expect afterwards.

Thanks
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Volume Control on PC Windows 10

23 Apr 2018, 10:06

https://autohotkey.com/download/ahk-install.exe

go here, install ahk unicode x64, create a blank txt file, paste two lines inside and save it, change its extension to .ahk, run it(preferably as admin), press left/right arrow keys to in-/decrease the volume
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

23 Apr 2018, 10:29

Please excuse my ignorance. To be sure, "txt file" you mean in Notepad? As I will presume & proceed per your instructions.

Will get back to you if need be.

Thanks
User avatar
JoeWinograd
Posts: 2165
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Volume Control on PC Windows 10

23 Apr 2018, 11:04

Hi David,
While swagfag's script will work, the problem is that the Left and Right arrow keys will always control the volume. In other words, you'll lose the use of the Left and Right arrow keys for their normal purpose in all programs. This is really untenable. If you're going to use that script, I suggest having a modifier key along with the Left and Right arrows, perhaps Alt or Ctrl or Shift, or maybe even two modifier keys, such as Alt+Ctrl or Ctrl+Shift. In AutoHotkey, here are the codes for the modifier keys:

Alt is !
Ctrl is ^
Shift is +
Win is # (that's the Windows logo key)

So, for example, the revised code using, say, Ctrl+Shift is:

Code: Select all

^+Left::SoundSet,-5
^+Right::SoundSet,+5
However, this is not going to give you the W10 horizontal slider. It will, indeed, increase/decrease the volume by 5% each time, but you won't see the slider. I'm not aware of any way to expose the W10 horizontal volume slider programmatically. You can expose the W10 vertical volume slider programmatically via the SndVol.exe command line (which could easily be called in an AutoHotkey script via the Run command), but not the horizontal one.

Since you're new to AutoHotkey, you may find my article helpful:
AutoHotkey - Getting Started

After that, I suggest tidbit's excellent tutorial at this site:
AutoHotkey Beginner Tutorial

Re controlling sound with AHK scripts, you may find another one of my articles to be helpful:
How to create an on/off toggle to mute the system audio/sound with a single mouse click or single keystroke

It would be very easy to modify the Mute/Unmute feature in that script to a VolumeUp/VolumeDown feature.

Welcome to the wonderful world of AutoHotkey! Regards, Joe
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

23 Apr 2018, 12:09

I received an error as follow:
Volume.ark
Error at line 1.
Line Text: Code: [Select all] [download] GeSH @ Codebox Plus
Error: This line does not contain a recognized action.
The program will exit.

----------------------------------------

Joe: 1) I seemed to be having an issues with the code provided to me (as shown above). 2) Actually the point you made regarding that the Left and Right arrow keys will always control the volume & I'll lose the use of the Left and Right arrow keys for their normal purpose in all programs in fact did cross my mind. However, the code in which you provided I don't quite follow. You seem to have the symbols, ^+ for both the left & right sound set... Can I use [Shift & ^+] for the Left and [Shift & ^-] for the right? Would this code work:


Code: [Select all] [Download] GeSHi © Codebox Plus

Shift^+Left::SoundSet,-5
Shift^-Right::SoundSet,+5
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: Volume Control on PC Windows 10

23 Apr 2018, 12:29

+ is - in this context of defining hotkeys - the shortcut for Shift. Please compare the tutorial: https://autohotkey.com/docs/Tutorial.htm#s21
Left stands for left arrow key: https://autohotkey.com/docs/KeyList.htm ... ntrol_keys

This works for me:

Code: Select all

+Left::SoundSet,-5      	; press Shift ("+") and left arrow key ("Left")
+Right::SoundSet,+5    		; Shift and right arrow
Please copy only the contents of the code box above (starting with "+Left..." ), and not the headers (Code: [Select all] [Download] GeSHi © Codebox Plus doesn't belong to the script code you should use) of the code box - the code box is just to make the code more readable. That means, copy the code you get, when you click 'Select all' in the header of the code box.
Last edited by gregster on 23 Apr 2018, 12:34, edited 1 time in total.
User avatar
JoeWinograd
Posts: 2165
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Volume Control on PC Windows 10

23 Apr 2018, 12:33

Hi David,
You don't put the word Shift (or Alt or Ctrl or Win) in the AutoHotkey script. You use just the symbol + (or ! or ^ or #).

The script should be what I put in my previous post. Also, each hotkey (and hotstring) should have a Return command so that you don't fall through to the code underneath it.
You seem to have the symbols, ^+ for both the left & right sound set
No, that's not what it means. The ^+ code means the Ctrl and Shift keys.
Can I use [Shift & ^+] for the Left and [Shift & ^-] for the right?
Yes, but your code will not work.

Here's the correct code for using Ctrl+LeftArrow and Ctrl+RightArrow:

Code: Select all

^Left::SoundSet,-5
^Right::SoundSet,+5
Return
Here's the correct code for using Shift+LeftArrow and Shift+RightArrow:

Code: Select all

+Left::SoundSet,-5
+Right::SoundSet,+5
Return
Here's the correct code for using Ctrl+Shift+LeftArrow and Ctrl+Shift+RightArrow:

Code: Select all

^+Left::SoundSet,-5
^+Right::SoundSet,+5
Return
As mentioned in my previous post, I think you would benefit greatly from my two articles and the tutorial here (all three links are in my previous post). Regards, Joe
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

23 Apr 2018, 20:32

Hey Joe! I got it to work! I used the Code:

+Left::SoundSet, -5
+Right::SoundSet, +5
Return

Some may see me as being greedy & ungrateful, bit I wish there was a way of exposing the W10 horizontal volume slider. Why? Sometimes I where headphones & sometimes not. I always like adjust/set my volume according to the (look,I'm going to look really stupid here for lack of the correct term) number (decimal) on the W10 horizontal volume control slider. But, that's just me.

Anyway, much thanks to you as well as to everyone else here.
User avatar
JoeWinograd
Posts: 2165
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Volume Control on PC Windows 10

24 Apr 2018, 00:21

Hi David,
I got it to work!
Great news!
I always like adjust/set my volume according to the...number (decimal) on the W10 horizontal volume control slider.
Ah, I've been wondering why you want the horizontal volume slider...now I get it. So try this script instead of what you've been using:

Code: Select all

#Warn,UseUnsetLocal
#NoEnv
#SingleInstance force
SetBatchLines,-1

SoundGet,Volume
Volume:=Round(Volume)
TrayTip:="Alt+LeftArrow or Alt+RightArrow to adjust volume" . "`nCurrent Volume=" . Volume
TrayIconFile:=A_WinDir . "\System32\DDORes.dll" ; get tray icon from DDORes.dll
TrayIconNum:="-2032" ; use headphones as tray icon (icon 2032 in DDORes)
Menu,Tray,Tip,%TrayTip%
Menu,Tray,Icon,%TrayIconFile%,%TrayIconNum%
Return

!Left::
SetTimer,SliderOff,3000
SoundSet,-1
Gosub,DisplaySlider
Return

!Right::
SetTimer,SliderOff,3000
SoundSet,+1
Gosub,DisplaySlider
Return

SliderOff:
Progress,Off
Return

DisplaySlider:
SoundGet,Volume
Volume:=Round(Volume)
Progress,%Volume%,%Volume%,Volume,HorizontalVolumeSliderW10
TrayTip:="Alt+LeftArrow or Alt+RightArrow to adjust volume" . "`nCurrent Volume=" . Volume
Menu,Tray,Tip,%TrayTip%
Return
In this script, I changed the volume-up and volume-down hotkeys to use Alt instead of Shift, because Shift+LeftArrow and Shift+RightArrow highlight/select text in many programs and I don't think it is a good idea to lose that functionality. However, change it to whatever you want, as I mentioned in a previous post:

Alt is !
Ctrl is ^
Shift is +
Win is # (that's the Windows logo key)

You may use more than one modifier key if you want, such as !^Left:: or ^+Left::. If you change the hotkeys, then change the ToolTip statements.

With this new script, you'll see a horizontal green bar with the volume number (from 0 to 100, in increments of 1), similar to the W10 horizontal volume slider. If you press the volume-up or volume-down hotkey in rapid succession (or keep it pressed), the horizontal green bar with the volume number (0-100) will stay on the screen. If you don't press either hotkey in 3 seconds, the horizontal green bar will automatically go away. I used headphones as the icon for this script in the system tray, but that can easily be changed to a speaker or a music note or whatever you prefer. Hovering on the icon gives a tool tip showing what hotkeys to use and the current volume level.

Let me know if this is to your satisfaction. Regards, Joe
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

24 Apr 2018, 11:15

Negative/no go Joe. I copied & pasted your script above & saw no a horizontal green bar with the volume number (from 0 to 100, in increments of 1).

I did changed the +Left:: & +Right:: (Shift arrow keys Left & Right) -to- ^Left:: &'^Right:: (Ctrl arrow keys Left & Right). Reason being, quite often I highlight text by double clicking on the Shift key & press on the Left & Right arrow keys. I don't believe this minor change had any effects on your code. I even deleted the AutoHot Key & created a new AutoHot Key with using the latest script. Again I know I'm repeating myself, when double clicking of the Ctrl key & pressing on the Left/Right arrow keys the volume will decrease/increase, however, no horizontal green bar appears.

I don't know Joe, I was happy when I saw that you realized & understood my reasoning, but the script seems not to be working for me. Might you have any other suggestions?

Be assure, I greatly appreciate your effort & time with me, Dave
User avatar
JoeWinograd
Posts: 2165
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Volume Control on PC Windows 10

24 Apr 2018, 11:29

Hi David,
It works perfectly here on W7 and W10. I suspect you copied it wrong or modified it wrong, although it could be something peculiar with your system. Let's try a different approach. I'm attaching the script to this post. I modified it to use the Ctrl key instead of Alt. Exit the script that's running now by right-clicking on the tray icon, then clicking Exit. Download the new script and run it. Regards, Joe
Attachments
HorizontalVolumeSliderW10.ahk
HorizontalVolumeSliderW10
(878 Bytes) Downloaded 1001 times
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

24 Apr 2018, 11:42

Joe, hang on & disregard my last post to you. I somehow got confused & didn't fully copied/pasted you script or ...I don't know. Let me try the last script again & I'll get back to you. I hope not to be bugging the sh*t out of you. :)
User avatar
JoeWinograd
Posts: 2165
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Volume Control on PC Windows 10

24 Apr 2018, 11:47

You're not bugging me at all. I'm happy to help. That's why this group exists...we help each other. I can't tell you how many times the good folks here have helped me with my scripts, and I've tried to help others whenever I have the expertise to do so. Regards, Joe
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

24 Apr 2018, 12:37

Joe I deleted & created a AutoHot Key entitled, "Volume." I didn't need need to download your attachment, but fully copied/pasted your last script (fully) & it worked!

Joe, don't I need to copy/paste this Volume AutoHot Key somewhere in my Start Up Folder? When I shutdown & start up again can I pressed the ALT+Left/Right arrow keys to prompt the horizontal volume control slider -or- will I need to tap on the Volume AutoHot Key icon on my desktop? Can you tell me (do you know how I can avoid this step & have the Volume AutoHot Key already activated upon each start-up of my PC?

I cannot thank you enough Joe!
User avatar
JoeWinograd
Posts: 2165
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Volume Control on PC Windows 10

24 Apr 2018, 12:49

Hi David,
I'm very glad to hear that it works for you and that it's what you want. Yes, you should place a shortcut to the script in your Startup folder. That way, it will run each time you boot Windows and it will always be available for you. Since you've installed AutoHotkey, it owns the file extension AHK, so all you have to do is create a shortcut to the script, such as C:\MyScripts\Volume.ahk and put that in the Startup folder. I do that for several AutoHotkey scripts, including the script that defines all of my hotkeys and hotstrings. Regards, Joe
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

24 Apr 2018, 13:03

Hey Joe, from a video I once watch regarding having AutoHot Keys be activated (I'm probably using the wrong term) upon start-up I followed these steps:

1) Hit the Win+R (bring up the Run Command Box)
2) Type in shell:common startup (opens up your Start Menu > Programs > Startup folder)
3) From your Desktop copy the particular AutoHot Key & paste it into your Start Menu > Programs > Startup folder

Does that sound right?
User avatar
JoeWinograd
Posts: 2165
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: Volume Control on PC Windows 10

24 Apr 2018, 13:29

Steps (1) and (2) are fine, but in step (3), you don't want to copy the actual AutoHotkey file. That will make a second copy in the Startup folder. You want to create a shortcut to the AutoHotkey file and put the shortcut in the Startup folder. To create the shortcut, right-click in File Explorer on your Volume.ahk file and then click Create shortcut. Then Cut (or Copy, but there's no reason to leave a copy of it) that shortcut into the Startup folder using steps (1) and (2). That way, whenever you change the script, you won't have to change anything in the Startup folder, since it points to the (one and only) copy of the actual script. Also, I suggest renaming the shortcut to Volume.lnk, although that's just cosmetic. Regards, Joe
djclinton18
Posts: 16
Joined: 21 Apr 2018, 18:16
Contact:

Re: Volume Control on PC Windows 10

24 Apr 2018, 19:31

Joe I'm having trouble creating a shortcut of my AutoHot key (entitled, "Volume," which is located on my Desktop. When I open my File Explorer, I cannot find the File, Volume.ahk; I even did a search on my OS & came up empty. When I Right-Click on the Volume (AutoHot Key) & select Edit Script, I check to see how it's Save As & it always is Save As, "Volume." When I try saving it as, Volume.ahk, it says that the file already exist, yet I cannot find it No offense to you, but this is starting to frustrate me

BTW, I don't think I'll be around/online tomorrow, but I ought to be back the day after tomorrow (Thurs.). Dave.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 58 guests