Jump to content

Manipulating volume levels


Recommended Posts

Hi all,

I've come across some VB code to manipulate things like master volume, WAVE, CD, MIDI etc. I've had a crack at converting it to AutoIt. Because it relies so heavily on pointers and DLL structures and Kernel32 calls, I'm not sure if I can trust myself to finish it.

Am I on the right track? Would it be worth asking for this functionality to be incorporated as a set of AutoIt functions?

Is anyone aware of an easier way to achieve this perhaps? Opening a mixer via WinMM seems to be the 'proper' way to do it (if the fact that the sliders in SndVol32 update with changes by the code is anything to go by). Ultimately I'm wanting to be able to set MIDI volume but it seems that only a small amount of extra work is needed to have the others controllable.

Link to post
Share on other sites

Thanks beerman.

You know, I never thought that something like this would be so complicated under the hood. This kind of code scares me with its talk of allocating memory on the heap and creating all sorts of structures...

I really want this functionality though. So I guess I'll try to keep heading towards it.

Link to post
Share on other sites

Thanks beerman.

You know, I never thought that something like this would be so complicated under the hood. This kind of code scares me with its talk of allocating memory on the heap and creating all sorts of structures...

I really want this functionality though. So I guess I'll try to keep heading towards it.

Here's one part for you http://www.autoitscript.com/forum/index.ph...indpost&p=82967

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to post
Share on other sites

maybe this could help

#include <GUIConstants.au3>



MsgBox(0,"", _SoundGetWaveVolume())


Func _SoundGetWaveVolume()
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
        SetError(2)
        Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
        $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
        SetError(1)
    EndIf
    DllStructDelete ($p)
    Return $WaveVol
EndFunc ;==>_SoundGetWaveVolume




run("sndvol32.exe")
WinWait("")
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGUP}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGUP}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGUP}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGDN}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGDN}")
sleep(1000)
ControlSend("Volume Control", "", "msctls_trackbar322", "{PGDN}")



Global Const $TBM_GETPOS = $TWM_USER
Func _GUICtrlSliderGetPos($h_slider)
   Local $ret
   $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_slider, "int", $TBM_GETPOS, "int", 0, "int", 0)
   Return $ret[0]
EndFunc ;==>_GUICtrlSliderGetPos

 $ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_slider, "int", $TBM_GETPOS, "int", 0, "int", 0)

8)

Edited by Valuater

NEWHeader1.png

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...