Jump to content


Gui volume slider for Windows 7


  • Please log in to reply
1 reply to this topic

#1 lblb

lblb
  • Guests

Posted 11 May 2012 - 09:20 AM

Hi,

This question may have been asked multiple times before but I haven't been able to find an example after extensive searches. So don't hesitate to just direct me to a relevant discussion that I may have missed. I'm very new to AutoHotkey so you may find that my questions reflect a misunderstanding of some very basic commands. Sorry about that!

All I'm trying to do is to add a slider on a Gui to control the volume. There are some great volume sliders in the scripts forum, but that's not what I need: I just need a simple slider on a Gui (and the Gui will be populated with other buttons).

Since I'm using Win 7 (64 bits), I understand that I can't use Soundget/Soundset and have tried to use VA.ahk. Note that I am using AutoHotkey basic, hence the #Include COM.ahk in the code below. For now, I have two main problems:
1) When I launch the script, I would like the slider to start at the current master volume level. That doesn't work yet. I thought that by defining volume_level as volume_level := VA_GetMasterVolume() and then using %volume_level% as the starting point for the slider could have worked, but no luck. (I've tried many variants)
2) All the volume sliders that are part of more complex Gui's that I could find use SoundSet to change the volume. I am trying to get it to work with VA_SetMasterVolume but I've somehow been completely unsuccessful. In the code below is an example that works (i.e. the master volume does change) but, as expected, it obviously doesn't do what I want as it increases the volume no matter in what direction the slider is moved. How can I get it to instead decrease the volume in one direction and increase it in the other?

Thanks in advance for all your help!

#Include VA.ahk
#Include COM.ahk
#SingleInstance Force

volume_level := VA_GetMasterVolume()
Gui,2:Add,Slider, x10  y10  h110  w20 vVolume Range0-100 vertical invert tickinterval10 AltSubmit gVolumeX, %volume_level%
Gui,2:show, h130 w50
return

VolumeX:
volume_level := VA_GetMasterVolume()
volume_level2 := volume_level + 2
VA_SetMasterVolume(volume_level2)
Return


#2 lblb

lblb
  • Guests

Posted 11 May 2012 - 09:22 AM

Just saw that I posted in the wrong section. Could anyone move it to Ask for help? Thanks!