Advertisement
mihaibr

Custom Volume Buttons and Custom Volume tray icons

Dec 2nd, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.53 KB | None | 0 0
  1. #include "SoundGetSetQuery.au3"
  2. Global $bState=False,$aIcon[4]=["low.ico","med.ico","max.ico","mute.ico"]
  3. $iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
  4. If $iVolume<=33 Then TraySetIcon($aIcon[0])
  5. If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
  6. If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
  7. HotKeySet("{PGUP}","up")
  8. HotKeySet("{PGDN}","down")
  9. HotKeySet("{INS}","mute")
  10. Func up()
  11.  
  12.     If $bState==False Then
  13.         $iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
  14.         Send("{VOLUME_UP}")
  15.         If $iVolume<=33 Then TraySetIcon($aIcon[0])
  16.         If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
  17.         If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
  18.     EndIf
  19. EndFunc
  20. Func down()
  21.     If $bState==False Then
  22.         $iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
  23.         Send("{VOLUME_DOWN}")
  24.         If $iVolume>=1 And $iVolume<=33 Then TraySetIcon($aIcon[0])
  25.         If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
  26.         If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
  27.         If $iVolume==0 Then TraySetIcon($aIcon[3])
  28.     EndIf
  29. EndFunc
  30. Func mute()
  31.     If $bState==True Then
  32.         $iVolume=_SoundGet(0, "dSpeakers", 1, "Volume")
  33.         Send("{VOLUME_MUTE}")
  34.         If $iVolume>=1 And $iVolume<=33 Then TraySetIcon($aIcon[0])
  35.         If $iVolume>33 And $iVolume<=66 Then TraySetIcon($aIcon[1])
  36.         If $iVolume>66 And $iVolume<=100 Then TraySetIcon($aIcon[2])
  37.         If $iVolume==0 Then TraySetIcon($aIcon[3])
  38.         $bState=False
  39.     Else
  40.         Send("{VOLUME_MUTE}")
  41.         TraySetIcon($aIcon[3])
  42.         $bState=True
  43.     EndIf
  44. EndFunc
  45. While True
  46.     Sleep(10)
  47. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement