g15 VLC Steuerung

  • da ich diese in delphi für mich weiter schreiben werde, veröffentliche ich hier mal meine erste lauffähige Autoit-Version
    Bis jetzt:
    -Titelanzeige über 2 Zeilen und Wechsel, falls noch länger
    -Zeitanzeige
    - Buttons: play/pause << >> mute

    Braucht:
    gtaspiders g15 lcd ansteuerung
    G15 LCD Fernsteuern mit Acitve-X
    und meine _vlc.au3

    Hauptskript:

    Spoiler anzeigen
    [autoit]

    #include <AvLCD.au3>
    #include <_vlc.au3>

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

    Global $LCDTitel = "VLC media Player G15"
    Global $t = ""
    Global $d = ""
    Global $r = 1
    Global $m = 0
    ;Global $v = False
    _StartLCD($LCDTitel)

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

    ;Global $hbuttonsBMP = _createvlcbuttons()

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

    While 1
    ;If ProcessExists("vlc.exe") Then
    ; If $v = False Then
    ;
    ; $v = True
    ; Else
    Switch _GetButtonState()
    Case 1
    _VLCPlayPause()
    sleep(500)
    Case 2
    _VLCPrevious()
    sleep(500)
    Case 4
    _VLCNext()
    sleep(500)
    Case 8
    _VLCMute()
    If $m = 0 Then
    $m = 1
    Else
    $m = 0
    EndIf
    sleep(500)
    EndSwitch
    _createvlcdisplay()
    ; EndIf
    ;Else
    ; _CloseLCD()
    ; $v = False
    ;EndIf
    sleep(20)
    WEnd

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

    Func _createvlcdisplay()
    ;$hBMP = _CreateLCDText("", 0, 0, 0, "Arial", 8, 0)
    ;If _VLC_IsPlaying() <> $t Then
    #cs $text = _VLC_IsPlaying()
    If StringLen($text) > 29 Then
    $aText = StringSplit($text, "")
    $text = ""
    For $i = 1 To 30
    $text &= $aText[$i]
    Next
    ;EndIf
    $hBMP = _CreateLCDText($text, 0, 0, 0, "Arial", 7, 0)
    $t = _VLC_IsPlaying()
    #ce EndIf
    If _VLC_PlayDuration() <> $d Then
    $d = _VLC_PlayDuration()
    ;$t = _VLC_IsPlaying()
    ;----> Erstellung des Titels
    $text = _VLC_IsPlaying()
    ;MsgBox(0,"", $text)
    If StringLen($text) > 29 Then
    $aText = StringSplit($text, "")
    $text = ""
    For $i = 1 To 30
    $text &= $aText[$i]
    Next
    If $aText[0] > 29 Then
    $text &= @CRLF
    If $aText[0] > 58 Then
    $iEnd = 58
    Else
    $iEnd = $aText[0]
    EndIf
    For $i = 30 To $iEnd
    $text &= $aText[$i]
    Next
    If $aText[0] > 58 Then
    If $r = 1 Then
    $text = ""
    If $aText[0] > 87 Then
    $iEnd = 87
    Else
    $iEnd = $aText[0]
    EndIf
    For $i = 59 To $iEnd
    $text &= $aText[$i]
    Next
    $r = 2
    Else
    $r = 1
    EndIf
    EndIf
    EndIf
    EndIf
    $hBMP = _CreateLCDText($text, 0, 0, 0, "Arial", 7, 0)
    ;$t = _VLC_IsPlaying()

    ;----> Erstellung der Zeit
    $hBMP = _CreateLCDText(_VLC_PlayDuration(), $hBMP, 45, 26, "Arial", 7, 0)

    ;----> Erstellung der Buttons
    If $m = 0 Then
    $LCDButtons = "play / pause << >> Mute"
    Else
    $LCDButtons = "play / pause << >> Unmute"
    EndIf
    $hBMP = _CreateLCDText($LCDButtons, $hBMP, 0, 36, "Arial", 5, 0)
    _ShowBitmap($hBMP)
    EndIf
    EndFunc

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

    #cs Func ReduceMemory($i_PID = -1)
    If $i_PID <> -1 Then
    Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle[0])
    DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
    Else
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf

    Return $ai_Return[0]
    #ce EndFunc

    [/autoit]

    _vlc.au3:
    steuert vlc über hotkeys(müssen auf Standart eingestellt sein)
    und liest Track und Zeit aus der Statusbar aus
    Ordnernamen etc werden über RegExp weggezaubert

    Spoiler anzeigen
    [autoit]

    #cs ----------------------------------------------------------------------------

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

    AutoIt Version: 3.2.12.0
    Author: Lev

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

    Script Function:
    VLC media player control

    Remarks:
    works only with standart hotkeys in vlc
    _VLC_IsPlaying() and _VLC_PlayDuration() requiere
    AutoItSetOption("WinTitleMatchMode", 2)
    so be carefull with your own formtitle!

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

    #ce ----------------------------------------------------------------------------

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

    ;#################################
    ; Returns a VLC toolbar handle if vlc is running
    ; remarks: if not found it returns 0
    ;#################################
    Func _StartVLC()
    $hToolbar = ControlGetHandle("VLC media player", "", "ToolbarWindow321")
    If @Error Then
    Return 0
    Else
    Return $hToolbar
    EndIf
    EndFunc ;==> _StartVLC

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

    Func _VLCPlayPause()
    ControlSend ("VLC media player", "", "", " ")
    ;WinActivate("VLC media player")
    ;_GUICtrlToolbar_ClickIndex($hVLCHandle, 2, "left", False)
    If @Error Then
    Return 0
    Else
    Return 1
    EndIf
    EndFunc ;==> _VLCPlayPause

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

    Func _VLCStop()
    ControlSend ("VLC media player", "", "", "s")
    ;_GUICtrlToolbar_ClickIndex($hVLCHandle, 3, "left", False)
    If @Error Then
    Return 0
    Else
    Return 1
    EndIf
    EndFunc ;==> _VLCStop

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

    Func _VLCPrevious()
    ControlSend ("VLC media player", "", "", "p")
    ;_GUICtrlToolbar_ClickIndex($hVLCHandle, 5, "left", False)
    If @Error Then
    Return 0
    Else
    Return 1
    EndIf
    EndFunc ;==> _VLCPrevious

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

    Func _VLCNext()
    ControlSend ("VLC media player", "", "", "n")
    ;_GUICtrlToolbar_ClickIndex($hVLCHandle, 8, "left", False)
    If @Error Then
    Return 0
    Else
    Return 1
    EndIf
    EndFunc ;==> _VLCNext

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

    Func _VLCMute()
    ControlSend ("VLC media player", "", "", "m")
    ;_GUICtrlToolbar_ClickIndex($hVLCHandle, 8, "left", False)
    If @Error Then
    Return 0
    Else
    Return 1
    EndIf
    EndFunc ;==> _VLCMute

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

    Func _VLC_IsPlaying()
    $isplaying = StringReplace(StringReplace(StatusbarGetText("VLC media player", "", 3),".mp3", ""), " - http://213.239.198.157:8000/", "")
    If $isplaying <> "" Then
    $isplaying = StringRegExpReplace ($isplaying, "\w{1}(:\\){1}(.*\\)*", "")
    Else
    $isplaying = "vlc currently plays nothing"
    EndIf
    If @Error Then
    Return "--"
    Else
    Return $isplaying
    EndIf
    EndFunc ;==> _VLC_IsPlaying

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

    Func _VLC_PlayDuration()
    $duration = StatusbarGetText("VLC media player", "", 1)
    If $duration = "" Then $duration = "0:00:00/-:--:--"
    If @Error Then
    Return "0:00:00/-:--:--"
    Else
    Return $duration
    EndIf
    EndFunc ;==> _VLC_PlayDuration

    [/autoit]

    hoffe damit kann jemand etwas anfangen, bzw sich selber etwas basteln
    und ich weiß wie chaotisch der code aussieht