Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region - TimeStamp
- ; 2012-07-29 01:01:10
- #EndRegion - TimeStamp
- #Include <Array.au3>
- $a = _Win7_SoundGetAll()
- _ArrayDisplay($a)
- ;~ ConsoleWrite( _Win7_SoundGetApp('Firefox') & @CRLF)
- ;~ ConsoleWrite( _Win7_SoundGetApp() & @CRLF)
- ;~ ConsoleWrite( _Win7_SoundGetApp('Flash') & @CRLF)
- ;~ ConsoleWrite( _Win7_SoundSetApp(50, 'Firefox') & @CRLF)
- ;~ ConsoleWrite( _Win7_SoundGetApp('Firefox') & @CRLF)
- ;===============================================================================
- ; Function Name....: _Win7_SoundGetAll
- ; Description......: Ermittelt vom Soundmixer: Anwendung, aktuelle Werte (inkl. Mastersound)
- ; Parameter(s).....: keine
- ; Requirement(s)...: OS Vista oder höher
- ; Return Value(s)..: 2D-Array [[Name Anwendung, Sound-Wert]]
- ; Author(s)........: BugFix ( bugfix@autoit.de )
- ;===============================================================================
- Func _Win7_SoundGetAll()
- Local $aRet, $dll = DllOpen('user32.dll')
- Local $iPID = Run("sndvol", '', @SW_MINIMIZE)
- Local $oldOpt = Opt("WinTitleMatchMode", 2)
- Local $hSoundMixer = WinWait("Lautstärkemixer")
- Opt("WinTitleMatchMode", $oldOpt)
- Local $aHWnd[1][2]
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hSoundMixer, "uint", 5)
- Local $hChildMix = $aRet[0]
- Local $hFirst = $hChildMix, $hAppsOuter, $hAppsInner, $hTmp, $hSub, $n = 0, $i = 0, $sText
- While $hFirst <> 0x0
- $aRet = DllCall($dll, "int", "GetClassNameW", "hwnd", $hFirst, "wstr", "", "int", 4096)
- If $aRet[2] = 'msctls_trackbar32' Then
- $aHWnd[0][0] = 'Master'
- $aRet = DllCall($dll, "int", "SendMessageW", "hwnd", $hFirst, "uint", 0x400, "wparam", 0, "lparam", 0)
- $aHWnd[0][1] = 100 - $aRet[0]
- EndIf
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hFirst, "uint", 2)
- $hFirst = $aRet[0]
- WEnd
- $hTmp = __Get_hTmp($dll, $hSoundMixer)
- While $hTmp <> 0x0
- If $aHWnd[UBound($aHWnd)-1][0] <> '' Then ReDim $aHWnd[UBound($aHWnd)+1][2]
- $aHWnd[UBound($aHWnd)-1][0] = $hTmp
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hTmp, "uint", 2)
- $hTmp = $aRet[0]
- $i += 1
- WEnd
- For $i = 1 To UBound($aHWnd)-1
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $aHWnd[$i][0], "uint", 5)
- $hSub = $aRet[0]
- $n = 0
- While $hSub <> 0x0
- $n += 1
- If $n = 3 Then
- $aRet = DllCall($dll, "int", "GetWindowTextW", "hwnd", $hSub, "wstr", "", "int", 4096)
- $sText = $aRet[2]
- ElseIf $n = 5 Then
- $aHWnd[$i][0] = $sText
- $aRet = DllCall($dll, "int", "SendMessageW", "hwnd", $hSub, "uint", 0x400, "wparam", 0, "lparam", 0)
- $aHWnd[$i][1] = 100 - $aRet[0]
- ExitLoop
- EndIf
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hSub, "uint", 2)
- $hSub = $aRet[0]
- WEnd
- Next
- DllClose($dll)
- ProcessClose($iPID)
- Return $aHWnd
- EndFunc ;==>_Win7_SoundGetAll
- ;===============================================================================
- ; Function Name....: _Win7_SoundGetApp
- ; Description......: Ermittelt von Anwendung den aktuelle Sound-Wert
- ; Parameter(s).....: $_sApp Name der Anwendung, Leerstring (Standard) gibt Mastervolume zurück
- ; Requirement(s)...: OS Vista oder höher
- ; Return Value(s)..: linearer Wert des Sound-Sliders
- ; Author(s)........: BugFix ( bugfix@autoit.de )
- ;===============================================================================
- Func _Win7_SoundGetApp($_sApp='')
- Local $aRet, $dll = DllOpen('user32.dll')
- Local $iPID = Run("sndvol", '', @SW_MINIMIZE)
- Local $oldOpt = Opt("WinTitleMatchMode", 2)
- Local $hSoundMixer = WinWait("Lautstärkemixer")
- Opt("WinTitleMatchMode", $oldOpt)
- Local $aHWnd[1][2]
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hSoundMixer, "uint", 5)
- Local $hChildMix = $aRet[0]
- Local $hFirst = $hChildMix, $hAppsOuter, $hAppsInner, $hTmp, $hSub, $n = 0, $i = 0, $sText
- While $hFirst <> 0x0
- $aRet = DllCall($dll, "int", "GetClassNameW", "hwnd", $hFirst, "wstr", "", "int", 4096)
- If $aRet[2] = 'msctls_trackbar32' Then
- $aHWnd[0][0] = $hFirst
- $aRet = DllCall($dll, "int", "SendMessageW", "hwnd", $hFirst, "uint", 0x400, "wparam", 0, "lparam", 0)
- $aHWnd[0][1] = 100 - $aRet[0]
- EndIf
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hFirst, "uint", 2)
- $hFirst = $aRet[0]
- WEnd
- If $_sApp = '' Then
- ProcessClose($iPID)
- DllClose($dll)
- Return $aHWnd[0][1]
- EndIf
- $hTmp = __Get_hTmp($dll, $hSoundMixer)
- While $hTmp <> 0x0
- If $aHWnd[UBound($aHWnd)-1][0] <> 0 Then ReDim $aHWnd[UBound($aHWnd)+1][2]
- $aHWnd[UBound($aHWnd)-1][0] = $hTmp
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hTmp, "uint", 2)
- $hTmp = $aRet[0]
- $i += 1
- WEnd
- For $i = 1 To UBound($aHWnd)-1
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $aHWnd[$i][0], "uint", 5)
- $hSub = $aRet[0]
- $n = 0
- While $hSub <> 0x0
- $n += 1
- If $n = 3 Then
- $aRet = DllCall($dll, "int", "GetWindowTextW", "hwnd", $hSub, "wstr", "", "int", 4096)
- $sText = $aRet[2]
- ElseIf $n = 5 Then
- $aHWnd[$i][0] = $sText
- $aRet = DllCall($dll, "int", "SendMessageW", "hwnd", $hSub, "uint", 0x400, "wparam", 0, "lparam", 0)
- $aHWnd[$i][1] = 100 - $aRet[0]
- ExitLoop
- EndIf
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hSub, "uint", 2)
- $hSub = $aRet[0]
- WEnd
- Next
- DllClose($dll)
- For $i = 1 To UBound($aHWnd)-1
- If StringInStr($aHWnd[$i][0], $_sApp) Then
- ProcessClose($iPID)
- Return $aHWnd[$i][1]
- EndIf
- Next
- ProcessClose($iPID)
- Return SetError(1,0,-1)
- EndFunc ;==>_Win7_SoundGetApp
- ;===============================================================================
- ; Function Name....: _Win7_SoundSetApp
- ; Description......: Setzt den aktuellen Sound-Wert für eine Anwendung od. Mastervolume
- ; Parameter(s).....: $_iValue zu setzender linearer Wert des Sound-Sliders
- ; .................: $_sApp Name der Anwendung, Leerstring (Standard) setzt Mastervolume
- ; Requirement(s)...: OS Vista oder höher
- ; Return Value(s)..: nichts
- ; Author(s)........: BugFix ( bugfix@autoit.de )
- ;===============================================================================
- Func _Win7_SoundSetApp($_iValue, $_sApp='')
- Local $aRet, $dll = DllOpen('user32.dll')
- Local $iPID = Run("sndvol", '', @SW_MINIMIZE)
- Local $oldOpt = Opt("WinTitleMatchMode", 2)
- Local $hSoundMixer = WinWaitActive("Lautstärkemixer")
- Opt("WinTitleMatchMode", $oldOpt)
- Local $aHWnd[1][2]
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hSoundMixer, "uint", 5)
- Local $hChildMix = $aRet[0]
- Local $hFirst = $hChildMix, $hAppsOuter, $hAppsInner, $hTmp, $hSub, $n = 0, $i = 0, $sText
- While $hFirst <> 0x0
- $aRet = DllCall($dll, "int", "GetClassNameW", "hwnd", $hFirst, "wstr", "", "int", 4096)
- If $aRet[2] = 'msctls_trackbar32' Then
- $aHWnd[0][0] = $hFirst
- If $_sApp = '' Then
- DllCall($dll, "int", "SendMessageW", "hwnd", $hFirst, "uint", 0x405, "wparam", 1, "lparam", 100 - $_iValue)
- DllClose($dll)
- Return ProcessClose($iPID)
- EndIf
- EndIf
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hFirst, "uint", 2)
- $hFirst = $aRet[0]
- WEnd
- $hTmp = __Get_hTmp($dll, $hSoundMixer)
- While $hTmp <> 0x0
- If $aHWnd[UBound($aHWnd)-1][0] <> 0 Then ReDim $aHWnd[UBound($aHWnd)+1][2]
- $aHWnd[UBound($aHWnd)-1][0] = $hTmp
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hTmp, "uint", 2)
- $hTmp = $aRet[0]
- $i += 1
- WEnd
- For $i = 1 To UBound($aHWnd)-1
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $aHWnd[$i][0], "uint", 5)
- $hSub = $aRet[0]
- $n = 0
- While $hSub <> 0x0
- $n += 1
- If $n = 3 Then
- $aRet = DllCall($dll, "int", "GetWindowTextW", "hwnd", $hSub, "wstr", "", "int", 4096)
- $sText = $aRet[2]
- ElseIf $n = 5 Then
- $aHWnd[$i][0] = $hSub
- $aHWnd[$i][1] = $sText
- ExitLoop
- EndIf
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $hSub, "uint", 2)
- $hSub = $aRet[0]
- WEnd
- Next
- For $i = 1 To UBound($aHWnd)-1
- If StringInStr($aHWnd[$i][1], $_sApp) Then
- DllCall($dll, "int", "SendMessageW", "hwnd", $aHWnd[$i][0], "uint", 0x405, "wparam", 1, "lparam", 100 - $_iValue)
- DllClose($dll)
- Return ProcessClose($iPID)
- EndIf
- Next
- EndFunc ;==>_Win7_SoundSetApp
- Func __Get_hTmp(ByRef $dll, $_hSoundMixer)
- Local $aRet
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $_hSoundMixer, "uint", 5)
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $aRet[0], "uint", 2)
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $aRet[0], "uint", 5)
- $aRet = DllCall($dll, "hwnd", "GetWindow", "hwnd", $aRet[0], "uint", 5)
- Return $aRet[0]
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement