nacerbaaziz

Detect if the audio output is changed

15 posts in this topic

#1 ·  Posted

Hello my friends
I have an urgent problem and we hope you can help me
I want to detect if the audio output of the device has changed
Such as the headset is connected or disConnected.
or change the default audio output
Is this possible?
I really searched a lot and found suggestions but unfortunately I did not understand them
Please explain to me
Greetings

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Um, I see that you haven't given enough detail in what approaches you have already taken and researched. This may be difficult for a blind person.

How about some code for what you already have done in this 'urgent' problem?

Is this related to the other post you made at https://www.autoitscript.com/forum/topic/189645-an-important-question-in-the-bassdll-file/ ?

Would the condensed summary of AutoIt at https://github.com/J2TeaM/awesome-AutoIt be of assistance?

Edited by Confuzzled

Share this post


Link to post
Share on other sites

#3 ·  Posted

Share this post


Link to post
Share on other sites

#4 ·  Posted

Sorry I want an example using autoit

Share this post


Link to post
Share on other sites

#5 ·  Posted

; _IMMNotificationClient

; By KaFu, based on this example by trancexx
; http://www.autoitscript.com/forum/topic/151474-looking-to-capture-immnotificationclientondevicestatechanged-events/#entry1084193


Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc($oError)
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc


; Global Const $sIID_IMMNotificationClient = "{7991EEC9-7E89-4D85-8390-6C703CEC60C0}"
Global Const $tagIMMNotificationClient = "OnDeviceStateChanged hresult(wstr;dword);" & _
        "OnDeviceAdded hresult(wstr);" & _
        "OnDeviceRemoved hresult(wstr);" & _
        "OnDefaultDeviceChanged hresult(dword;dword;wstr);" & _
        "OnPropertyValueChanged hresult(wstr;int64);" ; last param type is improvisation because AutoIt lacks proper type

Func _IMMNotificationClient_OnDeviceStateChanged($hresult, $wstr, $dword)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDeviceStateChanged" & @TAB & $wstr & @TAB & $dword & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDeviceStateChanged

Func _IMMNotificationClient_OnDeviceAdded($hresult, $wstr)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDeviceAdded" & @TAB & $wstr & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDeviceAdded

Func _IMMNotificationClient_OnDeviceRemoved($hresult, $wstr)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDeviceRemoved" & @TAB & $wstr & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDeviceRemoved

Func _IMMNotificationClient_OnDefaultDeviceChanged($hresult, $dword1, $dword2, $wstr)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDefaultDeviceChanged" & @TAB & $dword1 & @TAB & $dword2 & @TAB & $wstr & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDefaultDeviceChanged

Func _IMMNotificationClient_OnPropertyValueChanged($hresult, $wstr, $int64)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnPropertyValueChanged" & @TAB & $wstr & @TAB & $int64 & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnPropertyValueChanged

#cs
    Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}"
    Global Const $tagMyInterface = "FirstMethod hresult(wstr);" & _
    "SecondMethod hresult(int;wstr);"
#ce

Global $t_IMMNotificationClient
Global $o_IMMNotificationClient = ObjectFromDtag("_IMMNotificationClient_", $tagIMMNotificationClient, $t_IMMNotificationClient)
; Global $p_IMMNotificationClient = ptr($o_IMMNotificationClient())
Global $p_IMMNotificationClient = $o_IMMNotificationClient()

#cs
    ; Is object get?
    ConsoleWrite("!!! IsObj($oMyObject) = " & IsObj($o_IMMNotificationClient) & @CRLF)
    $o_IMMNotificationClient.OnDeviceRemoved("Test")
    ; Get object pointer:
    ConsoleWrite("+>>> Object pointer = " & $o_IMMNotificationClient() & @CRLF)
#ce

Func ObjectFromDtag($sFunctionPrefix, $tagInterface, ByRef $tInterface)
    Local Const $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _
            "AddRef dword();" & _
            "Release dword();"
    ; Adding IUnknown methods
    $tagInterface = $tagIUnknown & $tagInterface
    Local Const $PTR_SIZE = DllStructGetSize(DllStructCreate("ptr"))
    ; Below line really simple even though it looks super complex. It's just written weird to fit one line, not to steal your eyes
    Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace($tagInterface, "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "variant*", "ptr"), "hresult", "long"), "bstr", "ptr"), @LF, 3)
    Local $iUbound = UBound($aMethods)
    Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams
    ; Allocation. Read http://msdn.microsoft.com/en-us/library/ms810466.aspx to see why like this (object + methods):
    $tInterface = DllStructCreate("ptr[" & $iUbound + 1 & "]")
    If @error Then Return SetError(1, 0, 0)
    For $i = 0 To $iUbound - 1
        $aSplit = StringSplit($aMethods[$i], "|", 2)
        If UBound($aSplit) <> 2 Then ReDim $aSplit[2]
        $sNamePart = $aSplit[0]
        $sTagPart = $aSplit[1]
        $sMethod = $sFunctionPrefix & $sNamePart
        $aTagPart = StringSplit($sTagPart, ";", 2)
        $sRet = $aTagPart[0]
        $sParams = StringReplace($sTagPart, $sRet, "", 1)
        $sParams = "ptr" & $sParams
        DllStructSetData($tInterface, 1, DllCallbackGetPtr(DllCallbackRegister($sMethod, $sRet, $sParams)), $i + 2) ; Freeing is left to AutoIt.
    Next
    DllStructSetData($tInterface, 1, DllStructGetPtr($tInterface) + $PTR_SIZE) ; Interface method pointers are actually pointer size away
    Return ObjCreateInterface(DllStructGetPtr($tInterface), "", $tagInterface, False) ; and first pointer is object pointer that's wrapped
EndFunc   ;==>ObjectFromDtag



Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}"

Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _
        "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _
        "GetDevice hresult(wstr;ptr*);" & _
        "RegisterEndpointNotificationCallback hresult(ptr);" & _
        "UnregisterEndpointNotificationCallback hresult(ptr);"
Global $o_MMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator)


$o_MMDeviceEnumerator.RegisterEndpointNotificationCallback($p_IMMNotificationClient)
OnAutoItExitRegister("_UnregisterEndpointNotificationCallback")
Func _UnregisterEndpointNotificationCallback()
    $o_MMDeviceEnumerator.UnregisterEndpointNotificationCallback($p_IMMNotificationClient)
EndFunc   ;==>_UnregisterEndpointNotificationCallback


; ===================================================================================
; Main Loop
#include <Misc.au3>
While Sleep(10)
    If _IsPressed("1B") Then ExitLoop ; ESC to exit
WEnd

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Sorry dear
i not understand very well
please I want more clarification

Share this post


Link to post
Share on other sites

#7 ·  Posted

Share this post


Link to post
Share on other sites

#8 ·  Posted

Dear brother
to be  everything is clear for me
please provide this service to me
I want when I change the default audio output the script execute these commands
####
    _BASS_Free()
_BASS_Startup(@scriptDir & "\dll\bass.dll")
If @error = -1 Then
    MsgBox (0, "", "DLL Does not exist?  Please check file exists.")
    Exit
EndIf
_BASS_Init(0, -1, 44100, 0, "")
If @error Then
    MsgBox(0, "Error", "Could not initialize audio")
    Exit
EndIf
$MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
_BASS_ChannelSetDevice($MusicHandle, 1)
_BASS_ChannelSetvolume($MusicHandle, $volume)

autoefect()
_BASS_ChannelPlay($MusicHandle, 1)
_BASS_ChannelSetPosition($MusicHandle, $restartPlaying, $BASS_POS_BYTE)
###
I'm sorry if I upset you
greetings

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

; _IMMNotificationClient

; By KaFu, based on this example by trancexx
; http://www.autoitscript.com/forum/topic/151474-looking-to-capture-immnotificationclientondevicestatechanged-events/#entry1084193

Global $iAudioSwitched = 0

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc($oError)
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc


; Global Const $sIID_IMMNotificationClient = "{7991EEC9-7E89-4D85-8390-6C703CEC60C0}"
Global Const $tagIMMNotificationClient = "OnDeviceStateChanged hresult(wstr;dword);" & _
        "OnDeviceAdded hresult(wstr);" & _
        "OnDeviceRemoved hresult(wstr);" & _
        "OnDefaultDeviceChanged hresult(dword;dword;wstr);" & _
        "OnPropertyValueChanged hresult(wstr;int64);" ; last param type is improvisation because AutoIt lacks proper type

Func _IMMNotificationClient_OnDeviceStateChanged($hresult, $wstr, $dword)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDeviceStateChanged" & @TAB & $wstr & @TAB & $dword & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDeviceStateChanged

Func _IMMNotificationClient_OnDeviceAdded($hresult, $wstr)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDeviceAdded" & @TAB & $wstr & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDeviceAdded

Func _IMMNotificationClient_OnDeviceRemoved($hresult, $wstr)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDeviceRemoved" & @TAB & $wstr & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDeviceRemoved

Func _IMMNotificationClient_OnDefaultDeviceChanged($hresult, $dword1, $dword2, $wstr)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnDefaultDeviceChanged" & @TAB & $dword1 & @TAB & $dword2 & @TAB & $wstr & @CRLF)
    $iAudioSwitched = TimerInit()
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnDefaultDeviceChanged

Func _IMMNotificationClient_OnPropertyValueChanged($hresult, $wstr, $int64)
    #forceref $hresult
    ConsoleWrite("_IMMNotificationClient_OnPropertyValueChanged" & @TAB & $wstr & @TAB & $int64 & @CRLF)
    Return 0 ; S_OK
EndFunc   ;==>_IMMNotificationClient_OnPropertyValueChanged

#cs
    Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}"
    Global Const $tagMyInterface = "FirstMethod hresult(wstr);" & _
    "SecondMethod hresult(int;wstr);"
#ce

Global $t_IMMNotificationClient
Global $o_IMMNotificationClient = ObjectFromDtag("_IMMNotificationClient_", $tagIMMNotificationClient, $t_IMMNotificationClient)
; Global $p_IMMNotificationClient = ptr($o_IMMNotificationClient())
Global $p_IMMNotificationClient = $o_IMMNotificationClient()

#cs
    ; Is object get?
    ConsoleWrite("!!! IsObj($oMyObject) = " & IsObj($o_IMMNotificationClient) & @CRLF)
    $o_IMMNotificationClient.OnDeviceRemoved("Test")
    ; Get object pointer:
    ConsoleWrite("+>>> Object pointer = " & $o_IMMNotificationClient() & @CRLF)
#ce

Func ObjectFromDtag($sFunctionPrefix, $tagInterface, ByRef $tInterface)
    Local Const $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _
            "AddRef dword();" & _
            "Release dword();"
    ; Adding IUnknown methods
    $tagInterface = $tagIUnknown & $tagInterface
    Local Const $PTR_SIZE = DllStructGetSize(DllStructCreate("ptr"))
    ; Below line really simple even though it looks super complex. It's just written weird to fit one line, not to steal your eyes
    Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace($tagInterface, "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "variant*", "ptr"), "hresult", "long"), "bstr", "ptr"), @LF, 3)
    Local $iUbound = UBound($aMethods)
    Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams
    ; Allocation. Read http://msdn.microsoft.com/en-us/library/ms810466.aspx to see why like this (object + methods):
    $tInterface = DllStructCreate("ptr[" & $iUbound + 1 & "]")
    If @error Then Return SetError(1, 0, 0)
    For $i = 0 To $iUbound - 1
        $aSplit = StringSplit($aMethods[$i], "|", 2)
        If UBound($aSplit) <> 2 Then ReDim $aSplit[2]
        $sNamePart = $aSplit[0]
        $sTagPart = $aSplit[1]
        $sMethod = $sFunctionPrefix & $sNamePart
        $aTagPart = StringSplit($sTagPart, ";", 2)
        $sRet = $aTagPart[0]
        $sParams = StringReplace($sTagPart, $sRet, "", 1)
        $sParams = "ptr" & $sParams
        DllStructSetData($tInterface, 1, DllCallbackGetPtr(DllCallbackRegister($sMethod, $sRet, $sParams)), $i + 2) ; Freeing is left to AutoIt.
    Next
    DllStructSetData($tInterface, 1, DllStructGetPtr($tInterface) + $PTR_SIZE) ; Interface method pointers are actually pointer size away
    Return ObjCreateInterface(DllStructGetPtr($tInterface), "", $tagInterface, False) ; and first pointer is object pointer that's wrapped
EndFunc   ;==>ObjectFromDtag



Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}"

Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _
        "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _
        "GetDevice hresult(wstr;ptr*);" & _
        "RegisterEndpointNotificationCallback hresult(ptr);" & _
        "UnregisterEndpointNotificationCallback hresult(ptr);"
Global $o_MMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator)


$o_MMDeviceEnumerator.RegisterEndpointNotificationCallback($p_IMMNotificationClient)
OnAutoItExitRegister("_UnregisterEndpointNotificationCallback")
Func _UnregisterEndpointNotificationCallback()
    $o_MMDeviceEnumerator.UnregisterEndpointNotificationCallback($p_IMMNotificationClient)
EndFunc   ;==>_UnregisterEndpointNotificationCallback


; ===================================================================================
; Main Loop
#include <Misc.au3>
While Sleep(10)

    ; If _IsPressed("1B") Then ExitLoop ; ESC to exit

    if $iAudioSwitched and TimerDiff($iAudioSwitched) > 250 then
        ConsoleWrite("Audio switched" & @crlf)
        
            _BASS_Free()
            _BASS_Startup(@scriptDir & "\dll\bass.dll")
            If @error = -1 Then
                MsgBox (0, "", "DLL Does not exist?  Please check file exists.")
                Exit
            EndIf
            _BASS_Init(0, -1, 44100, 0, "")
            If @error Then
                MsgBox(0, "Error", "Could not initialize audio")
                Exit
            EndIf
            $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
            _BASS_ChannelSetDevice($MusicHandle, 1)
            _BASS_ChannelSetvolume($MusicHandle, $volume)

            autoefect()
            _BASS_ChannelPlay($MusicHandle, 1)
            _BASS_ChannelSetPosition($MusicHandle, $restartPlaying, $BASS_POS_BYTE)
        
        $iAudioSwitched = 0
    endif

WEnd

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

Hello again
can you correct the errors in this file after you adjust it according to what suits me. please

When I use it I am having many errors
I want it as an include file
to use it in my program
Please help me dear!
Greetings to all

audioOutputIsChanged.au3

Share this post


Link to post
Share on other sites

#11 ·  Posted

Hello , good morning


Is there anyone who can help me to correct the previous include file?
I could not correct it with  myself

thank you.

Share this post


Link to post
Share on other sites

#12 ·  Posted

Hello
First, I want to apologize to you on this issue
I urgently need to convert this code into an include file and simplify it

 

; _IMMNotificationClient

; By KaFu, based on this example by trancexx
; http://www.autoitscript.com/forum/topic/151474-looking-to-capture-immnotificationclientondevicestatechanged-events/#entry1084193

Global $iAudioSwitched = 0

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc($oError)
ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc


; Global Const $sIID_IMMNotificationClient = "{7991EEC9-7E89-4D85-8390-6C703CEC60C0}"
Global Const $tagIMMNotificationClient = "OnDeviceStateChanged hresult(wstr;dword);" & _
"OnDeviceAdded hresult(wstr);" & _
"OnDeviceRemoved hresult(wstr);" & _
"OnDefaultDeviceChanged hresult(dword;dword;wstr);" & _
"OnPropertyValueChanged hresult(wstr;int64);" ; last param type is improvisation because AutoIt lacks proper type

Func _IMMNotificationClient_OnDeviceStateChanged($hresult, $wstr, $dword)
#forceref $hresult

Return 0 ; S_OK
EndFunc

Func _IMMNotificationClient_OnDeviceAdded($hresult, $wstr)
#forceref $hresult
Return 0 ; S_OK
EndFunc

Func _IMMNotificationClient_OnDeviceRemoved($hresult, $wstr)
#forceref $hresult
Return 0 ; S_OK
EndFunc

Func _IMMNotificationClient_OnDefaultDeviceChanged($hresult, $dword1, $dword2, $wstr)
#forceref $hresult
$iAudioSwitched = TimerInit()
Return 0 ; S_OK
EndFunc

Func _IMMNotificationClient_OnPropertyValueChanged($hresult, $wstr, $int64)
#forceref $hresult

Return 0 ; S_OK
EndFunc

#cs
Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}"
Global Const $tagMyInterface = "FirstMethod hresult(wstr);" & _
"SecondMethod hresult(int;wstr);"
#ce

Global $t_IMMNotificationClient
Global $o_IMMNotificationClient = ObjectFromDtag("_IMMNotificationClient_", $tagIMMNotificationClient, $t_IMMNotificationClient)
; Global $p_IMMNotificationClient = ptr($o_IMMNotificationClient())
Global $p_IMMNotificationClient = $o_IMMNotificationClient()

#cs
; Is object get?
ConsoleWrite("!!! IsObj($oMyObject) = " & IsObj($o_IMMNotificationClient) & @CRLF)
$o_IMMNotificationClient.OnDeviceRemoved("Test")
; Get object pointer:
ConsoleWrite("+>>> Object pointer = " & $o_IMMNotificationClient() & @CRLF)
#ce

Func ObjectFromDtag($sFunctionPrefix, $tagInterface, ByRef $tInterface)
Local Const $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _
"AddRef dword();" & _
"Release dword();"
; Adding IUnknown methods
$tagInterface = $tagIUnknown & $tagInterface
Local Const $PTR_SIZE = DllStructGetSize(DllStructCreate("ptr"))
; Below line really simple even though it looks super complex. It's just written weird to fit one line, not to steal your eyes
Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace($tagInterface,"\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "variant*", "ptr"), "hresult", "long"),"bstr", "ptr"), @LF, 3)
Local $iUbound = UBound($aMethods)
Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams
; Allocation. Read http://msdn.microsoft.com/en-us/library/ms810466.aspx to see why like this (object + methods):
$tInterface = DllStructCreate("ptr[" & $iUbound + 1 & "]")
If @error Then Return SetError(1, 0, 0)
For $i = 0 To $iUbound - 1
$aSplit = StringSplit($aMethods[$i], "|", 2)
If UBound($aSplit) <> 2 Then ReDim $aSplit[2]
$sNamePart = $aSplit[0]
$sTagPart = $aSplit[1]
$sMethod = $sFunctionPrefix & $sNamePart
$aTagPart = StringSplit($sTagPart, ";", 2)
$sRet = $aTagPart[0]
$sParams = StringReplace($sTagPart, $sRet, "", 1)
$sParams = "ptr" & $sParams
DllStructSetData($tInterface, 1, DllCallbackGetPtr(DllCallbackRegister($sMethod, $sRet, $sParams)), $i + 2) ; Freeing is left to AutoIt.
Next
DllStructSetData($tInterface, 1, DllStructGetPtr($tInterface) + $PTR_SIZE) ; Interface method pointers are actually pointer size away
Return ObjCreateInterface(DllStructGetPtr($tInterface), "", $tagInterface, False) ; and first pointer is object pointer that's wrapped
EndFunc

 

Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}"

Global Const $tagIMMDeviceEnumerator = "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _
"GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _
"GetDevice hresult(wstr;ptr*);" & _
"RegisterEndpointNotificationCallback hresult(ptr);" & _
"UnregisterEndpointNotificationCallback hresult(ptr);"
Global $o_MMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $tagIMMDeviceEnumerator)


$o_MMDeviceEnumerator.RegisterEndpointNotificationCallback($p_IMMNotificationClient)
OnAutoItExitRegister("_UnregisterEndpointNotificationCallback")
Func _UnregisterEndpointNotificationCallback()
$o_MMDeviceEnumerator.UnregisterEndpointNotificationCallback($p_IMMNotificationClient)
EndFunc


; ===================================================================================
; Main Loop


FUNC outputChanged()
if $iAudioSwitched and TimerDiff($iAudioSwitched) > 250 then
$iAudioSwitched = 0
RETURN 1
ELSE
$iAudioSwitched = 0
RETURN 0
endif

EndFunc

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

1 hour ago, nacerbaaziz said:

nnm

Edited by MattHiggs

Share this post


Link to post
Share on other sites

#14 ·  Posted

19 minutes ago, MattHiggs said:

 

Sorry but I did not understand what you said

Share this post


Link to post
Share on other sites

#15 ·  Posted

Is there any suggestion about how to  do this file as a include file please?

I mean the file in comment above

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

  • Similar Content

    • way1000
      By way1000
      i'm trying to create a program that let's the user type a word in an input field (gui) and when a button is pressed the letters of the word are replaced by 1 word each from a list of words in a text file
      i created the gui for it but i need help to add some more code to make it work like intented

      each letter of a word should be replaced by a word from a text file
      the text file is a source for replacing letters is a file with 2 columns separated by tab that contains the entire alphabet (26 rows)
       
      please help if possible
       
      i posted an example gui screenshot

    • nss
      By nss
      Hi all,
       
      I am making a program in which I use Bass audio library (with the wrapper for autoit that I found here on forums I think) because of its support for dx effects.
      My problem, though, is that when effects as reverb or echo/delay are added, the channel length is not extended as to fit the tail of the effect, so if the file was really short, you wouldn't even hear the reverb at all.
      I've tried setting the  buffer parameter even to 60k ms, updating the channel length to 60k ms, but nothing makes it so that the effects aren't being cut off.
      I've heard that I could add silence manually to wave files by adding the chr(0) characters, but haven't had any luck doing that, either.
      What I'm doing:
      initialize bass use streamCreateFile to load the wave file with the fx flag and length parameter set to 60000 set the config buffer to 60000 use channel set fx to add dx8 reverb use channel play to play the sound use bass update to update the length to 60000  
      I even tried having only silence in one wave file and tried joining two wave files together, but that didn't work either.
       
      Any help would be very much appreciated.
    • nacerbaaziz
      By nacerbaaziz
      Hi guys
      I have an inquiry please
      I want an example of how to add an icon file to the compiled autoit file and how to use it in GUICtrlCreateIcon
      Preferably in a separate list within the resourceFor example myIcons
      I hope my request is clear and I hope you will help me solve this problem
      Because I found an example in the help files but I did not understand the method well
    • nacerbaaziz
      By nacerbaaziz
      hello
      Greetings to all
      dears i have a big problem in the bass.dll
      e.g
      If you play an audio file using the bass.dll
      and  You changed the audio output
      Such as setting or removing headphones
      The sound output of bass.dll does not change
      Is there any solution
      If it exists, please give it to me
      Greetings and thanks in advance
      I apologize for my bad English