Jump to content

IsMute() for Vista - a start


Recommended Posts

Hi All,

I want a function to check whether a Vista computer is muted or not. I found this thread, which works on XP machines and started trying to adapt it for Vista. This is what I've got:

run("sndvol.exe","")
winwait("Volume Mixer")
$mute_query= ControlCommand ("Volume Mixer","","[TEXT:&Main Mute]","IsChecked" )
If $mute_query=1 Then
    msgbox(1,"","Audio is muted.")
Else
    msgbox(1,"","Audio isn't muted.")
EndIf
WinClose("Volume Mixer")

The problem is with the ControlCommand line, in the XP version the mute is a check box which can be checked, in the Vista mixer it is a button which I can find using the ControlCommand as shown above but can't check if it is checked or not, when you press it a small red x in a circle is added to the button, but it doesn't seem to be checked as such.

Any ideas what I could do next gratefully recieved.

Thanks,

Steph

Link to comment
Share on other sites

Hi,

this works on XP SP2

$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
        Run('sndvol32', '', @SW_HIDE)
        $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

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thanks,

That's the same technique as in the thread I linked to earlier, unfortunately it doesn't work in Vista where sndvol32 has been replaced with sndvol and instead of a check box which can be checked for easily as in the code you posted there is a button. The button doesn't seem to have a pressed state, instead when you press it the picture changes as I describe in the original post. So I'm wondering if there is another way to check whether the sound is muted or whether I can check the button in some other way.

Thanks,

Stephan

Link to comment
Share on other sites

added this to audio.au3. Thanks Xenobiologist!

Beware that it is a semi-professionel solution and I only tested it on XP SP2.

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 1 month later...

Thanks,

That's the same technique as in the thread I linked to earlier, unfortunately it doesn't work in Vista where sndvol32 has been replaced with sndvol and instead of a check box which can be checked for easily as in the code you posted there is a button. The button doesn't seem to have a pressed state, instead when you press it the picture changes as I describe in the original post. So I'm wondering if there is another way to check whether the sound is muted or whether I can check the button in some other way.

Thanks,

Stephan

Perhaps you can check for a certain pixel's colour?

If the picture changes, there must be at least one pixel which changes colour, so if you see what colour that pixel is in the muted and unmuted states, and then just use PixelGetColor, you'll know whether it's muted or not.

Link to comment
Share on other sites

Perhaps you can check for a certain pixel's colour?

If the picture changes, there must be at least one pixel which changes colour, so if you see what colour that pixel is in the muted and unmuted states, and then just use PixelGetColor, you'll know whether it's muted or not.

Hi,

using Pixel functions the window needs to be visible which is ... :D

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...