soundDetectTest.au3 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "soundDetect.au3"
  2. Local $ui = GUICreate('Level', 30, 150, 100,100, Default, 0x00000008)
  3. Local $ProgressBar = GUICtrlCreateProgress(10, 10, 10, 115, 0x04)
  4. GUISetState(@SW_HIDE, $ui)
  5. HotKeySet("{F5}","terminate")
  6. Local $showPeakLevel = true
  7. Local $appDotExe = "Wow.exe"
  8. Local $debug = true
  9. ;================================================
  10. while 1
  11. if ($debug == true) then debugMode()
  12. if ($showPeakLevel == true) then
  13. GUISetState(@SW_SHOW, $ui)
  14. Local $peakLevel = getApplicationPeakLevel($appDotExe)
  15. If ($peakLevel > 78) and ($debug == true) Then MsgBox(64, 'Its over 99', 'Too Loud. Neighbours will be angry')
  16. GUICtrlSetData($ProgressBar, $peakLevel)
  17. ConsoleWrite($peakLevel & " - " & $appDotExe & @crlf)
  18. EndIf
  19. ;Sleep(100)
  20. WEnd
  21. ;================================================
  22. Func getApplicationPeakLevel($appDotExe)
  23. $aApp = _GetAppsPlayingSound()
  24. If (UBound($aApp)>1) then
  25. For $i= 0 to UBound($aApp)-1
  26. If ($aApp[$i][0] == $appDotExe) then
  27. return Int($aApp[$i][1]*100)
  28. EndIf
  29. Next
  30. EndIf
  31. return 0
  32. EndFunc
  33. Func debugMode()
  34. Local $str = ""
  35. $aApp = _GetAppsPlayingSound()
  36. If (UBound($aApp)>1) then
  37. For $i= 0 to UBound($aApp)-1
  38. $str = $str & Int($aApp[$i][1]*100) & " - " & $aApp[$i][0] & @CRLF
  39. Next
  40. ToolTip($str, 1, 1)
  41. EndIf
  42. return 0
  43. EndFunc
  44. Func terminate()
  45. GUIDelete($ui)
  46. Exit
  47. EndFunc