fader() [UDF]

Veröffentliche deine funktionierenden Skripte und Funktionen

Moderator: jNizM

BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

fader() [UDF]

15 Jun 2017, 15:53

Code: Select all

; Zum Testen als fader().ahk abspeichern und direkt (aus dem editor) ausführen. 

if (A_ScriptName = "fader().ahk"){          ; Test section. You've to change that script name setting accordingly!
    Random, Percent,1,80                    ; OK, let's select a random percentage value that is used for ...
    fader(Percent,12,"T")                   ; ... de-/increasing the volume, with a delay of 12*10ms (between each step), and let's display a progress "T"oolTip
    Sleep, 1000                       
    fader(14)                               ; Next try: de-/increase the volume to 14% [, but use the default delay (of 5ms), and show no ToolTip]
    Sleep, 1000
    fader(30,0.1)                           ; Final try: de-/increase the volume to 30%, using a delay of 0.1*10ms [, but show no ToolTip]
    ExitApp
    }

fader(reqVol,speed=5,display="") {          ; requested volume (in %), delay between each step (*10ms, default=5), display progress "T"oolTip
    speed   := speed*10                     ; calculate delay
    SoundGetWaveVolume, curVol              ; get current volume
    curVol  :=  SuBStr(curVol,1,-7)         ; get rid of floating point number (for cosmetical reason)
    symbol  := reqVol < curVol ? "-" : "+"  ; decide if to de-/increase the volume
    lCount  := Abs(reqVol - curVol)         ; set loop counter to be a positive number (loop won't run with a negative nmber)
    Loop % lCount {
      If (display = "T")                    ; show ToolTip if requested
        ToolTip % "cur:`t" curVol "`nreq:`t" reqVol "`ndiff:`t" symbol . A_Index
      Sleep,% speed                         ; BoBo proudly presents "the delay"
      SoundSetWaveVolume,% symbol . "1"     ; fading (de-/increase) the volume
      }
    ToolTip
    }
:)
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: fader() [UDF]

11 Jul 2017, 11:59

<reserviert>

Return to “Skripte und Funktionen”

Who is online

Users browsing this forum: No registered users and 4 guests