音量条频率
```#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>
;a simple level indicator (of whatever)...
;change it to fit your needs
;by taietel
; I will use values in the range 0-100.
; For other ranges, you have to modify the script accordingly
Global $hLblValue ; label to show the values
$gui=GUICreate("GUI", 120, 150,-1,-1,$WS_POPUP,$WS_EX_LAYERED)
GUISetBkColor(0xabcdef)
;initialize the levelmeter
;example fragmented
$a = _CreateLevelMeter(5,5)
$b = _CreateLevelMeter(40,5,False,20,5,30,0xFFFFFF,0x0000FF)
;example continuous
$c = _CreateLevelMeter(75,5,True,20,5,30,0x00FF00,0xFFFF00)
_WinAPI_SetLayeredWindowAttributes($gui,0xabcdef)
GUISetState()
;and display some random values
For $i=1 To 100
$s1=Random(0,100,1)
$s2=Random(0,100,1)
$s3=Random(0,100,1)
_ShowLevelMeter($a, $s1)
_ShowLevelMeter($b, $s2)
_ShowLevelMeter($c, $s3)
Sleep(100)
Next
Sleep(2000)
Exit
While 1
Sleep(10)
Switch GUIGetMsg()
Case -3
Exit
EndSwitch
WEnd
Func _CreateLevelMeter($iX=5, $iY=5, $bContinous=False, $iUnits=20, $iUnitHeight=5, $iUnitWidth=30, $lStartColour=0xFFFF00, $lEndColour=0xFF0000,$hLblValue="")
Local $iUH, $arIndicator[$iUnits], $arColours[$iUnits]
Local $arRet[$iUnits][4]
If $bContinous = False Then
$iUH = $iUnitHeight+1
Else
$iUnitHeight+=1
$iUH = $iUnitHeight
EndIf
;label to show some values (optional)
$hLblValue = GUICtrlCreateLabel("", $iX, $iY+$iUH*$iUnits+$iUH+5, $iUnitWidth, 18,$SS_CENTER)
GUICtrlSetColor(-1,0xFF0000)
$Ri = Mod($lStartColour,256)
$Gi = BitAND($lStartColour/256,255)
$Bi = BitAND($lStartColour/65536,255)
$Rf = Mod($lEndColour,256)
$Gf = BitAND($lEndColour/256,255)
$Bf = BitAND($lEndColour/65536,255)
$Rs = Abs($Ri - $Rf)/$iUnits
$Gs = Abs($Gi - $Gf)/$iUnits
$Bs = Abs($Bi - $Bf)/$iUnits
If $Rf < $Ri Then $Rs = -$Rs
If $Gf < $Gi Then $Gs = -$Gs
If $Bf < $Bi Then $Bs = -$Bs
For $i=0 To $iUnits-1
$Rf = $Ri + $Rs * $i
$Gf = $Gi + $Gs * $i
$Bf = $Bi + $Bs * $i
$arColours[$i]="0x"&Hex($Bf,2) & Hex($Gf,2) & Hex($Rf,2)
Next
For $i=0 To $iUnits-1
$arIndicator[$i] = GUICtrlCreateLabel("", $iX, ($iY+$iUH*$iUnits)-$iUH*$i, $iUnitWidth, $iUnitHeight)
$arRet[$i][0]=$arIndicator[$i]
$arRet[$i][1]=$arColours[$i]
$arRet[$i][2]=$iUnits
$arRet[$i][3]=$hLblValue
Next
Return $arRet
EndFunc
Func _ShowLevelMeter(ByRef $avArray, $Signal,$iMinValue=0,$iMaxValue=100)
GUICtrlSetData($avArray[0][3], $Signal)
Local $iUnitsColoured
Local $m = Mod($Signal, $avArray[0][2])
Switch $m
Case 0
$iUnitsColoured=($Signal-$m)*$avArray[0][2]/100
Case Else
$iUnitsColoured=($Signal-$m)*$avArray[0][2]/100 + 1
EndSwitch
For $i=0 To $iUnitsColoured-1
GUICtrlSetBkColor($avArray[$i][0], $avArray[$i][1])
Next
For $j=UBound($avArray)-1 To $iUnitsColoured Step -1
GUICtrlSetBkColor($avArray[$j][0], $GUI_BKCOLOR_TRANSPARENT)
Next
EndFunc```
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!