Öffnen mit... (mit meinem Programm öffnen)

  • Hi leute, ich habe eine frage, ist es möglich eine Dateityp mit meinem Programm zu öffnen z.B. ein MP3 Format?
    Wenn ja könnte mir es einer erklären wie es geht, wäre echt nett danke!
    Habe auch ein Bild hochgeladen damit man es besser versteht. :)

    MfG

    M3HM3T

    Einmal editiert, zuletzt von m3hm3t (23. Juni 2008 um 17:09)

  • Erstmal danke für die Antwort.
    Ja das ist mir schon klar, aber wenn ich es dann mit meinem Programm öffne dann wird die Datei nicht geöffnet wie hier im Beispiel die Sound datei wird nicht abgespielt.

    Hier der Code zu meinem Media Player, falls ihr benötigt:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <ButtonConstants.au3>
    #include <Sound.au3>
    #NoTrayIcon

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

    Global $opendialog, $sound, $o = 0, $p = 0, $length

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

    FileInstall("mediaplayerxxl.bmp", @TempDir & "\mediaplayerxxl.bmp", 1)
    FileInstall("play.bmp", @TempDir & "\play.bmp", 1)
    FileInstall("pause.bmp", @TempDir & "\pause.bmp", 1)
    FileInstall("stop.bmp", @TempDir & "\stop.bmp", 1)
    FileInstall("played.bmp", @TempDir & "\played.bmp", 1)
    FileInstall("paused.bmp", @TempDir & "\paused.bmp", 1)

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

    HotKeySet("^o", "open")
    HotKeySet("{F1}", "info")

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

    GUICreate("Media Player XXL", 500, 470)
    GUISetBkColor(0x000000)

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

    $menu = GUICtrlCreateMenu("Datei")
    $menu2 = GUICtrlCreateMenu("?")

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

    $itemopen = GUICtrlCreateMenuItem("Öffnen..." & @TAB & "Strg+O", $menu)
    GUICtrlCreateMenuItem("", $menu, -1)
    $itemexit = GUICtrlCreateMenuItem("Beenden", $menu)
    $iteminfo = GUICtrlCreateMenuItem("Info" & @TAB & "F1", $menu2)

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

    GUICtrlCreatePic(@TempDir & "\mediaplayerxxl.bmp", 5, 5, 489, 176)

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

    $play = GUICtrlCreateButton("", 15, 212, 50, 40, $BS_BITMAP)
    GUICtrlSetImage(-1, @TempDir & "\play.bmp")
    $pause = GUICtrlCreateButton("", 70, 212, 50, 40, $BS_BITMAP)
    GUICtrlSetImage(-1, @TempDir & "\pause.bmp")
    $stop = GUICtrlCreateButton("", 125, 212, 50, 40, $BS_BITMAP)
    GUICtrlSetImage(-1, @TempDir & "\stop.bmp")

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

    GUICtrlCreateGroup("Lautstärke", 190, 200, 140, 55)
    $slider = GUICtrlCreateSlider(200, 220, 120, 25)
    GUICtrlSetData(-1, 100)

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

    $file = GUICtrlCreateButton("Öffnen...", 360, 220, 100, 25)

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

    $list = GUICtrlCreateList("", 10, 280, 480, 140)

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

    $label = GUICtrlCreateLabel("00:00:00 / 00:00:00", 200, 425, 200, 25)
    GUICtrlSetColor(-1, 0xffffff)

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

    GUISetState()

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

    While 1
    $msg = GUIGetMsg()

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

    Switch $msg
    Case $GUI_EVENT_CLOSE, $itemexit
    FileDelete(@TempDir & "\mediaplayerxxl.bmp")
    FileDelete(@TempDir & "\play.bmp")
    FileDelete(@TempDir & "\pause.bmp")
    FileDelete(@TempDir & "\stop.bmp")
    FileDelete(@TempDir & "\played.bmp")
    FileDelete(@TempDir & "\paused.bmp")
    Exit
    Case $file
    open()
    Case $play
    If $o = 0 Then
    $sound = _SoundOpen(GUICtrlRead($list))
    _SoundPlay($sound) ; Sound wird abgespielt
    GUICtrlSetImage($play, @TempDir & "\played.bmp")
    AdlibEnable("pos", 1000) ; Hier wird die Funktion pos aktiviert
    $o = 1
    EndIf
    If $p = 1 Then
    _SoundResume($sound) ; Sound wird Repausiert
    GUICtrlSetImage($play, @TempDir & "\played.bmp")
    GUICtrlSetImage($pause, @TempDir & "\pause.bmp")
    $p = 0
    EndIf
    Case $pause
    If $p = 0 Then
    _SoundPause($sound) ; Sound wird Pausiert
    GUICtrlSetImage($play, @TempDir & "\play.bmp")
    GUICtrlSetImage($pause, @TempDir & "\paused.bmp")
    $p = 1
    EndIf
    Case $stop
    _SoundClose($sound) ; Sound wird geschlossen
    GUICtrlSetImage($play, @TempDir & "\play.bmp")
    GUICtrlSetImage($pause, @TempDir & "\pause.bmp")
    AdlibDisable() ; Hier wird die Funktion pos deaktiviert
    $o = 0
    Case $slider
    SoundSetWaveVolume(GUICtrlRead($slider))
    Case $iteminfo
    info()
    EndSwitch

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

    WEnd

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

    Func pos()
    $length = _SoundLength($sound, 1) ; Hier wird angegeben wie lang der Sound in Zeit ist
    $pos = _SoundPos($sound, 1) ; Hier wird die aktuelle Zeit angegeben
    GUICtrlSetData($label, $pos & " / " & $length)
    EndFunc

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

    Func open()
    $opendialog = FileOpenDialog("Öffnen...", "", "Medien (*.mp3; *.wav)", 4)
    GUICtrlSetData($list, $opendialog)
    EndFunc

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

    Func info()
    MsgBox(64, "Info", "Media Player XXL" & @CRLF & "Version 1.0.0.0" & @CRLF & "" & @CRLF & "Copyright © 2008, by M3HM3T")
    EndFunc

    [/autoit]

    Wäre echt nett wenn ihr mir helfen könnt.

    4 Mal editiert, zuletzt von m3hm3t (22. Juni 2008 um 14:06)

  • hoffe ich habe dich richtig verstanden und es funktioniert auch :rolleyes:

    [autoit]

    Run('C:\programme\winamp\winamp.exe "C:\WINDOWS\Media\Windows XP-Startvorgang.wav"')

    [/autoit]
  • Danke für die Antwort Tweaky, aber das was du hier beschrieben hast ist ja auch nur auf eine Datei bestimmt, wenn du verstehst was ich meine.

    Einmal editiert, zuletzt von m3hm3t (22. Juni 2008 um 14:45)

  • Du willst also das ganze fest mit deinem Programm verknüfen?
    Dann mußt du es über die Registry machen.
    Google mal da wirst du sicher fündig

  • ja genau das meine ich, das habe ich mir schon gedacht das ich es mit dem registry machen muss.
    Aber das Problem ist das er die betroffene Datei nicht öffnen wenn ich es mit meinem Programm öffnen lasse.

    Edit:
    Ich habe mich mal im Google umgesehen, und weiß das man was im HKEY_CLASSES_ROOT erstellen muss um es zu verknüpfen.
    Aber wie genau muss ich es machen?

    Einmal editiert, zuletzt von m3hm3t (22. Juni 2008 um 14:43)

  • Hi du kannst es auch im Arbeitsplatz und zwar so:
    Unter Extras auf Ordneroptionen,
    dort dann auf Datentypen, hier kannst du dann vorhandene datentypen bearbeiten, aber auch ganz neue hinzufügen.

    MfG Night

  • Danke für die Antwort, aber das weiß ich auch.
    Nun einer der sich nicht so auskennt, weiß dann nicht wie man es als Standard Editor Einstellt, deshalb möchte ich auch eine Anwendung schreiben die es dann im Registry als Standard einträgt.

    Bloß wie ist die genaue schreibweise? ?(

  • Das Problem liegt darin, dass du dein Programm dafür auch kompatibel machen musst.
    Das gleiche gilt auch für das Drag & Drop Prinzip.
    D.h., dass es auch (noch) nicht möglich ist, dass du eine mp3 Datei in deinen Media Player ziehen kannst. Denn das Programm weiß (noch) nicht, was damit gemeint ist.
    Ich habe leider auch keine Ahnung, wie man das genau anstellt.
    Aber ich denke mal etwa so:

    [autoit]

    While 1
    sleep (100) ; für die GUI
    If ;hier kommt ein Befehl rein, der quasi irgendein Input überprüft (Drag & Drop oder öffnen mit...)
    _DeineFunktion ()
    Else
    Continue Loop
    Endif
    Wend

    [/autoit]


    Hoffe, ich konnte etwas helfen.

    Gruß

  • Danke Snify, ich hoffe es das es einer hier ergänzen kann mit dem oben genannten Code.
    Ich bedanke mich schon mal im vorraus.

    Edit: Weiß keiner wie ich es schreiben könnte damit das funktioniert.

    Einmal editiert, zuletzt von m3hm3t (22. Juni 2008 um 20:33)

  • DANKE für den Link, Progandy!

    da ich aber nicht so gut in Englisch bin, verstehe ich das auch nicht so ganz und mit dem Beispiel Code kann ich auch nicht sehr viel anfangen.
    Ich bitte um Verständis. :S

  • Danke FirePanther aber das Problem besteht noch darin wenn ich es mit meinem Media Player z.B. öffnen lasse dann wird der Sound nicht abgespielt.

  • Hi !

    Ich habe deinen Code etwas erweitert. Mit dem Code aus dem Link den dir progandy gegeben hat.
    Die play() Funktion ist nicht zu 100 % ausgereift.
    Ist auch nur ein Ansatz wie man es machen kann.

    LG Concara

    Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>
    #include <ButtonConstants.au3>
    #include <Sound.au3>
    #NoTrayIcon
    Global $opendialog, $sound, $o = 0, $p = 0, $length
    FileInstall("mediaplayerxxl.bmp", @TempDir & "\mediaplayerxxl.bmp", 1)
    FileInstall("play.bmp", @TempDir & "\play.bmp", 1)
    FileInstall("pause.bmp", @TempDir & "\pause.bmp", 1)
    FileInstall("stop.bmp", @TempDir & "\stop.bmp", 1)
    FileInstall("played.bmp", @TempDir & "\played.bmp", 1)
    FileInstall("paused.bmp", @TempDir & "\paused.bmp", 1)
    HotKeySet("^o", "open")
    HotKeySet("{F1}", "info")
    GUICreate("Media Player XXL", 500, 470)
    GUISetBkColor(0x000000)
    $menu = GUICtrlCreateMenu("Datei")
    $menu2 = GUICtrlCreateMenu("?")
    $itemopen = GUICtrlCreateMenuItem("Öffnen..." & @TAB & "Strg+O", $menu)
    GUICtrlCreateMenuItem("", $menu, -1)
    $itemexit = GUICtrlCreateMenuItem("Beenden", $menu)
    $iteminfo = GUICtrlCreateMenuItem("Info" & @TAB & "F1", $menu2)
    GUICtrlCreatePic(@TempDir & "\mediaplayerxxl.bmp", 5, 5, 489, 176)
    $play = GUICtrlCreateButton("", 15, 212, 50, 40, $BS_BITMAP)
    GUICtrlSetImage(-1, @TempDir & "\play.bmp")
    $pause = GUICtrlCreateButton("", 70, 212, 50, 40, $BS_BITMAP)
    GUICtrlSetImage(-1, @TempDir & "\pause.bmp")
    $stop = GUICtrlCreateButton("", 125, 212, 50, 40, $BS_BITMAP)
    GUICtrlSetImage(-1, @TempDir & "\stop.bmp")
    GUICtrlCreateGroup("Lautstärke", 190, 200, 140, 55)
    $slider = GUICtrlCreateSlider(200, 220, 120, 25)
    GUICtrlSetData(-1, 100)
    $file = GUICtrlCreateButton("Öffnen...", 360, 220, 100, 25)
    $list = GUICtrlCreateList("", 10, 280, 480, 140)
    $label = GUICtrlCreateLabel("00:00:00 / 00:00:00", 200, 425, 200, 25)
    GUICtrlSetColor(-1, 0xffffff)
    Dim $filename
    ;$cmdline[0] is the number of parameters passed
    If $cmdline[0] <> 0 Then
    $filename = $cmdline[1]
    ; Do something with the file here
    MsgBox(0, "UXYFixer", 'The file name passed to the command line is "' & $filename & '"')
    GUICtrlSetData($list, $filename)
    play()
    Else
    ; We did not get any command line parameters.
    ; If this is a command line only program, you would want to
    ; alert the user that the command line parameters were incorrect.
    ; If this is a GUI program (like a notepad program), you would
    ; want to simply continue from here without opening a file.
    MsgBox(0, "UXYFixer", 'Command line parameters incorrect.' & @CRLF & 'Command line usage: "' & @ScriptName & '" "file to process"')
    EndIf
    GUISetState()

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

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE, $itemexit
    FileDelete(@TempDir & "\mediaplayerxxl.bmp")
    FileDelete(@TempDir & "\play.bmp")
    FileDelete(@TempDir & "\pause.bmp")
    FileDelete(@TempDir & "\stop.bmp")
    FileDelete(@TempDir & "\played.bmp")
    FileDelete(@TempDir & "\paused.bmp")
    Exit
    Case $file
    open()
    Case $play
    play()
    Case $pause
    If $p = 0 Then
    _SoundPause($sound) ; Sound wird Pausiert
    GUICtrlSetImage($play, @TempDir & "\play.bmp")
    GUICtrlSetImage($pause, @TempDir & "\paused.bmp")
    $p = 1
    EndIf
    Case $stop
    _SoundClose($sound) ; Sound wird geschlossen
    GUICtrlSetImage($play, @TempDir & "\play.bmp")
    GUICtrlSetImage($pause, @TempDir & "\pause.bmp")
    AdlibDisable() ; Hier wird die Funktion pos deaktiviert
    $o = 0
    Case $slider
    SoundSetWaveVolume(GUICtrlRead($slider))
    Case $iteminfo
    info()
    EndSwitch
    WEnd
    Func play()
    If $filename = "" Then
    If $o = 0 Then
    $sound = _SoundOpen(GUICtrlRead($list))
    _SoundPlay($sound) ; Sound wird abgespielt
    GUICtrlSetImage($play, @TempDir & "\played.bmp")
    AdlibEnable("pos", 1000) ; Hier wird die Funktion pos aktiviert
    $o = 1
    EndIf
    Else
    $sound = $filename
    _SoundPlay($sound) ; Sound wird abgespielt
    GUICtrlSetImage($play, @TempDir & "\played.bmp")
    AdlibEnable("pos", 1000) ; Hier wird die Funktion pos aktiviert
    $o = 1
    $filename = ""
    EndIf
    If $p = 1 Then
    _SoundResume($sound) ; Sound wird Repausiert
    GUICtrlSetImage($play, @TempDir & "\played.bmp")
    GUICtrlSetImage($pause, @TempDir & "\pause.bmp")
    $p = 0
    EndIf
    EndFunc
    Func pos()
    $length = _SoundLength($sound, 1) ; Hier wird angegeben wie lang der Sound in Zeit ist
    $pos = _SoundPos($sound, 1) ; Hier wird die aktuelle Zeit angegeben
    GUICtrlSetData($label, $pos & " / " & $length)
    EndFunc
    Func open()
    $opendialog = FileOpenDialog("Öffnen...", "", "Medien (*.mp3; *.wav)", 4)
    GUICtrlSetData($list, $opendialog)
    EndFunc
    Func info()
    MsgBox(64, "Info", "Media Player XXL" & @CRLF & "Version 1.0.0.0" & @CRLF & "" & @CRLF & "Copyright © 2008, by M3HM3T")
    EndFunc

    [/autoit]

    If not :?: then ?( else :thumbup:

    Einmal editiert, zuletzt von Concara (23. Juni 2008 um 11:51)

  • Ich mache es beim Datenschredder per cmd.exe,
    bei Batch musste in der Registry bei shell/open nach dem Eintrag

    Zitat

    C:\test.exe "%1"

    zum Beispiel.
    Mit DOS kannste dann einfach

    Code
    xcopy %1 C:\verschiebehierhin


    oder

    Code
    echo %1


    sagen.
    Wie du siehst,wird der Pfad damit übergeben.

    Sei kreativ :rolleyes:

    Zitat

    Programmieren ist so lange lustig bis ein Fehler auftritt!


    ~ Dankeschön

  • Danke Concara, jetzt geht es.
    Bloß ich verstehe jetzt nicht ganz mit dem

    [autoit]

    $cmdline[0]

    [/autoit]

    ?!?!

  • Aus der Hife:

    Spoiler anzeigen

    Running ScriptsCommand Line Parameters
    The special array $CmdLine is
    initialized with the command line parameters passed in to your AutoIt script.
    Note the scriptname is not classed as a parameter; get this information with
    @ScriptName instead. A parameter that contains spaces must be surrounded by
    "double quotes". Compiled scripts accept command line parameters in the
    same way.

    $CmdLine[0] is
    number of parameters
    $CmdLine[1] is param 1 (after the
    script name)
    $CmdLine[2] is
    param 2 etc
    ...
    $CmdLine[$CmdLine[0]] is one way to get the last
    parameter...


    So if your script is run like this:

    AutoIt3.exe myscript.au3 param1 "this is another param"

    $CmdLine[0] equals...
    2

    $CmdLine[1] equals...
    param1

    $CmdLine[2] equals...
    this is another param

    @ScriptName equals... myscript.au3


    In addition to $CmdLine there
    is a variable called $CmdLineRaw that contains the entire command line unsplit,
    so for the above example:

    $CmdLineRaw equals... myscript.au3 param1 "this is
    another param"


    If the script was compiled it would have been run like this:

    myscript.exe param1 "this is another param"

    $CmdLineRaw equals... param1 "this is another
    param"

    Note that $CmdLineRaw just return the parameters.


    Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will
    always returns the entire command line.

    (gibt es noch nicht übersetzt )