Sign in to follow this  
Followers 0
WannaLearn

[Solved]_isMute in Win7?

6 posts in this topic

#1 ·  Posted (edited)

Hi, all.

English is not my first language, so please be nice and tell me if I make mistakes.

I want to mute the master volume when Hotkey1 is pressed and unmute it when Hotkey2 is pressed.

I used the Send('{VOLUME_MUTE}') to mute and unmute.

However, when I press the Hotkey1 twice, it unmute the master volume.

I wanted to check the mute status and determine whether to send the command or not.

Here is my script

Hotkeyset('+{F2}','Mute')
Hotkeyset('^{F2}','Unmute')

Func Mute()
If _isMute(1000) = 0 Then
    Send('{VOLUME_MUTE}')
Elseif _isMute(1000) = 1 Then
    MsgBox(0,'Mute','Already Muted',3)
Else
    ConsoleWrite('Error occured when trying to mute'&@crlf)
EndIf
EndFunc

Func Unmute()
If _isMute(1000) = 1 Then
    Send('{VOLUME_MUTE}')
Elseif _isMute(1000) = 0 Then
    MsgBox(0,'Unmute','Already Unmuted',3)
Else
    ConsoleWrite('Error occured when trying to unmute'&@crlf)
EndIf
EndFunc

while 1

WEnd


;~ $re = _isMute(1000)
;~ If @error Then ConsoleWrite(@error & @CRLF)
;~ ConsoleWrite($re & @CRLF)
;===============================================================================
;
; Function Name:  _isMute
; Description::   Check for mute sound
; Parameter(s):   ControlID
;    Voulme            = 1000
;    Wave             = 2000
;    SW-Synthesizer     = 3000
;    CD-Player         = 4000
;    Mikrofon         = 5000
;    Line-In         = 6000
; Requirement(s):  ---
; Return Value(s): 0 = not muted, 1 = muted, -1 = timeout, -2 = ControlID not found
; Author(s):       Thorsten Meger (Xenobiologist)
;
;===============================================================================

Func _isMute($opt = 1000)
    Local $retVal = 0, $ex = False
    If Not WinExists('[CLASS:Volume Control]') Then
        If @OSVersion = 'WIN_XP' Then
            Run('sndvol32', '', @SW_HIDE)
        Else
            Run('sndvol', '', @SW_HIDE)
        EndIf
        $ex = True
    EndIf
    If WinWait('[CLASS:Volume Control]', '', 2) = 0 Then Return -1
    $retVal = ControlCommand('[CLASS:Volume Control]', '', $opt, 'isChecked')
    If @error Then Return -2
    If $ex = True Then WinClose('[CLASS:Volume Control]')
    Return $retVal
EndFunc  ;==>_isMute

I have googled about it and found out that sndvol was rebuilt from the ground since Vista and that's why _isMute() is not working any more.

I also found a guy said taht he was able to check the mute status by using winmm.dll and mixergetControlDetails function at here.

However, I have no clue how to or what to do with it...

Any help?

Edited by WannaLearn

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Also look into trancexx's - there she defines the same IAudioEndpointVolume interface that the above plugin uses, but in this case it works in both 64-bit and 32-bit modes and doesn't require extra redistributables.

The problem is it would need to be extracted from the player and put into a UDF of its own, which would require a little effort.

*edit: links

Edited by Ascend4nt

Share this post


Link to post
Share on other sites

Thank you so much for replies.

Both are really long scripts...

I'm trying to figure it out which part should I use.

Please wish me a good luck :x

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I don't really understand the mechanism how this works...

Somehow I thought I got this working but... it wasn't :x

I should try even harder...

Edited by WannaLearn

Share this post


Link to post
Share on other sites

I don't really understand the mechanism how this works...

Somehow I thought I got this working but... it wasn't :)

I should try even harder...

Finally, It's working!!!

Thank you for your kind reply.

All I had to add was

_AutoItObject_StartUp()

at the beginning.

I used entire _AudioVolObject function ^^

And here I post my result, a nBossKey!!

You can set hotkeys for hiding/show windows.

You can also set almost any activated window to fullscreen mode.

Because of your help, I could be able to add a must function to it.

Thank you again and I post my result here.

nBossKey.exe

Share this post


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
Sign in to follow this  
Followers 0