Advertisement
flypip

Flytape (detecteur de son)

Nov 22nd, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.66 KB | None | 0 0
  1.  
  2. ; taper dans vos main il dit le nombre de tape. pour l'aretter taper plus de 4 fois.
  3. #Include <string.au3>
  4. ;--------------------
  5. $cde1=""
  6. $cde2=""
  7. $cde3=""
  8. ;--------------------
  9. if $CmdLine[0]>0 then
  10.     $cde1=$CmdLine[1]
  11. endif
  12. if $CmdLine[0]>1 then
  13.     $cde2=$CmdLine[2]
  14. endif
  15. if $CmdLine[0]>2 then
  16.     $cde3=$CmdLine[3]
  17. endif
  18.  
  19. ;--------------------
  20.  
  21. $VoiceActivationLevel = 40
  22. $level=0
  23. ;--------------------
  24. Func _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback)
  25.     Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0)
  26. EndFunc
  27. ;--------------------
  28. Func _mciShowError($mciError,$add = "test")
  29.     Dim $errStr
  30.     $errStr = _StringRepeat(" ", 256)
  31.     $Result = DllCall("winmm.dll", "long", "mciGetErrorStringA", "long", $mciError, "string", $errStr, "long", StringLen($errStr))
  32.     MsgBox(0, "MCI "&$add, "MCI Error Number " & $mciError & ":" & $Result[2])
  33. EndFunc
  34. ;--------------------
  35. Func ClapCheck()
  36.     Global $lpszCommand,$lpszReturnString,$cchReturn,$level
  37.     $level=0
  38.     $mciError = _mciSendString("status tempwave level", $lpszReturnString, $cchReturn, 0)
  39.     If $mciError[0]<>0 Then
  40.         MsgBox(0,"Erreur MCI 37 ; ",$mciError[0])
  41.     EndIf
  42.     If $mciError[2]>0 Then
  43.         $level=$mciError[2]
  44.     EndIf
  45.     If $level >= $VoiceActivationLevel Then
  46.         $retombe=$level
  47.         While $retombe >= $VoiceActivationLevel
  48.             $mciError = _mciSendString("status tempwave level", $lpszReturnString, $cchReturn, 0)
  49.             $retombe = $mciError[2]
  50.             sleep(6)
  51.         WEnd
  52.     EndIf
  53. EndFunc
  54.  
  55. ;--------------------
  56.  
  57. $lpszReturnString = _StringRepeat(" ", 256)
  58. $cchReturn = StringLen($lpszReturnString)
  59. $mciError = _mciSendString("open new type waveaudio alias tempwave", $lpszReturnString, $cchReturn, 0);
  60. If $mciError[0] <> 0 Then
  61.     _mciShowError($mciError[0],"Startup Error")
  62.     Exit
  63. EndIf
  64.  
  65. ;--------------------
  66.  
  67. $interv=20
  68. $delaimaxientre2clics = Int(600/$interv)  
  69. $ClapCount = 0
  70. $i=$delaimaxientre2clics
  71.  
  72. Global $level
  73. $level=0
  74.  
  75. ;--------------------
  76.  
  77. While 1
  78.     Sleep($interv)
  79.     $i-=1
  80.     If $i<=0 Then
  81.         If $ClapCount>0 Then
  82.             If $ClapCount>3 Then
  83.                 MsgBox(0,"Flytape","Fin du programme",2)
  84.                 ExitLoop
  85.             EndIf
  86.            
  87.             MsgBox(0,"flytape","nombre de tape "&$ClapCount,1)
  88.                        
  89.         EndIf
  90.         $i=$delaimaxientre2clics
  91.         $ClapCount=0
  92.     EndIf
  93.  
  94.     $level=0
  95.     ClapCheck()
  96.     If $level >= $VoiceActivationLevel Then
  97.         $ClapCount +=1
  98.         $i=$delaimaxientre2clics
  99.        
  100.     EndIf
  101. WEnd
  102. Exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement