ChesTeRcs %!s(int64=6) %!d(string=hai) anos
pai
achega
5c24bae547
Modificáronse 2 ficheiros con 67 adicións e 15 borrados
  1. 1 15
      soundDetect.au3
  2. 66 0
      soundDetectTest.au3

+ 1 - 15
soundDetect.au3

@@ -64,25 +64,12 @@ Global Const $sTagIAudioSessionControl2 = $sTagIAudioSessionControl & "GetSessio
 
 Global $bExit= not False
 
-HotKeySet("{F5}","_Exit")
 
-_WinAPI_CoInitialize()
 
+_WinAPI_CoInitialize()
 Local $aApp =0
 
-While $bExit
-$aApp = _GetAppsPlayingSound()
-If (UBound($aApp)>1) then
-For $i= 0 to UBound($aApp)-1
-ConsoleWrite(Int($aApp[$i][1]*100) & " - " & $aApp[$i][0] & @CRLF)
-ControlSetText('', '', 'Scintilla2', '')
-Next
-EndIf
-Sleep(100)
-WEnd
-
 
-_WinAPI_CoUninitialize()
 
 Func _Exit()
 $bExit=False
@@ -108,7 +95,6 @@ Func _GetAppsPlayingSound()
     Local $ProcessID = 0
     Local $fPeakValue = 0
     Local $iState = 0
-    Local $iVolume = 10
     Local $oErrorHandler = 0
 
     $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

+ 66 - 0
soundDetectTest.au3

@@ -0,0 +1,66 @@
+#include "soundDetect.au3"
+Local $ui = GUICreate('Level', 30, 150, 100,100, Default, 0x00000008)
+Local $ProgressBar = GUICtrlCreateProgress(10, 10, 10, 115, 0x04)
+GUISetState(@SW_HIDE, $ui)
+HotKeySet("{F5}","terminate")
+
+
+Local $showPeakLevel = true
+Local $appDotExe = "Wow.exe"
+Local $debug = true
+
+
+
+
+;================================================
+while 1
+   if ($debug == true) then debugMode()
+   if ($showPeakLevel == true) then
+	  GUISetState(@SW_SHOW, $ui)
+	  Local $peakLevel = getApplicationPeakLevel($appDotExe)
+	  If ($peakLevel > 78) and ($debug == true) Then MsgBox(64, 'Its over 99', 'Too Loud. Neighbours will be angry')
+	  GUICtrlSetData($ProgressBar, $peakLevel)
+	  ConsoleWrite($peakLevel & " - " & $appDotExe & @crlf)
+   EndIf
+   ;Sleep(100)
+WEnd
+
+
+
+
+
+
+
+
+
+;================================================
+Func getApplicationPeakLevel($appDotExe)
+   $aApp = _GetAppsPlayingSound()
+   If (UBound($aApp)>1) then
+	  For $i= 0 to UBound($aApp)-1
+		 If ($aApp[$i][0] == $appDotExe) then
+			return Int($aApp[$i][1]*100)
+		 EndIf
+	  Next
+   EndIf
+   return 0
+EndFunc
+
+
+Func debugMode()
+   Local $str = ""
+   $aApp = _GetAppsPlayingSound()
+   If (UBound($aApp)>1) then
+	  For $i= 0 to UBound($aApp)-1
+		 $str = $str & Int($aApp[$i][1]*100) & " - " & $aApp[$i][0] & @CRLF
+	  Next
+	  ToolTip($str, 1, 1)
+   EndIf
+   return 0
+EndFunc
+
+
+Func terminate()
+  GUIDelete($ui)
+  Exit
+EndFunc