timingproblem

  • ich hab folgendes timingproblem ich lese die lautsctärke aus kann aber nicht setzen weil sie immer neu ausgelesen wird
    wenn ich sleep einbaue verzögert sich die gui zusehr was nun?

    Spoiler anzeigen
    [autoit]

    #Region Loop
    While 1 ;* Sleep(20)
    $volget = _SoundGetWaveVolume()
    GUICtrlSetData($volume_slider2,$volget)
    wend

    [/autoit] [autoit][/autoit] [autoit]

    Func _SoundGetWaveVolume()
    Sleep(10)
    Local $WaveVol = -1, $p, $ret
    Const $MMSYSERR_NOERROR = 0
    $p = DllStructCreate ("dword")
    If @error Then
    SetError(2)
    Return -2
    EndIf
    $ret = DllCall("winmm.dll", "long", "waveOutGetVolume", "long", -1, "long", DllStructGetPtr ($p))
    If ($ret[0] == $MMSYSERR_NOERROR) Then
    $WaveVol = Round(Dec(StringRight(Hex(DllStructGetData ($p, 1), 8), 4)) / 0xFFFF * 100)
    Else
    SetError(1)
    EndIf
    $p=""
    Return $WaveVol
    EndFunc ;==>_SoundGetWaveVolume
    #EndRegion Func's

    [/autoit]
  • Hallo JuraX,

    versuch es so:

    [autoit]

    While 1 ;* Sleep(20)
    $volget = _SoundGetWaveVolume()
    if $volget <> GuiCtrlRead($volume_slider2) then GUICtrlSetData($volume_slider2,$volget)
    wend

    [/autoit]


    vernünftiger wäre es allerdings direkt auf den Slider zu reagieren, hier ein DEMO:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <SliderConstants.au3>
    #include <GuiSlider.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $iPercent

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $hGui = GUICreate("Test", 275, 145, 193, 150)
    $hGroup = GUICtrlCreateGroup("Der Wert beträgt jetzt: 0%.", 8, 8, 260, 79)
    $hSlider = GUICtrlCreateSlider(13, 23, 250, 49, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_Bottom, $TBS_ENABLESELRANGE, $TBS_TOOLTIPS))
    GUICtrlSetLimit($hSlider, 100, 0) ;maximal 100 minimal 0
    GUICtrlCreateGroup("", -99, -99, 1, 1) ; Gruppe schliessen
    $hButton1 = GUICtrlCreateButton("OK", 64, 96, 145, 33, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    _GUICtrlSlider_SetPageSize($hSlider, 10)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $hSlider
    $iPercent = Ceiling(GUICtrlRead($hSlider) / 10) * 10 ;Sliderwert auf 10er Zahlen runden
    GUICtrlSetData($hSlider, $iPercent) ;gerundeten Wert anzeigen
    GUICtrlSetData($hGroup, "Der Wert beträgt jetzt: " & $iPercent & "%.")
    Case $hButton1
    ;$iPercent = Int(GUICtrlRead($hSlider) / 10)
    Switch $iPercent
    Case 10
    MsgBox(0, "", "10")
    Case 20
    MsgBox(0, "", "20")
    Case 30
    MsgBox(0, "", "30")
    Case 40
    MsgBox(0, "", "40")
    Case 50
    MsgBox(0, "", "50")
    Case 60
    MsgBox(0, "", "60")
    Case 70
    MsgBox(0, "", "70")
    Case 80
    MsgBox(0, "", "80")
    Case 90
    MsgBox(0, "", "90")
    Case 100
    MsgBox(0, "", "100")
    EndSwitch
    EndSwitch
    WEnd

    [/autoit]

    mfg (Auto)Bert