Morsecode'er

  • Tach zusamm.
    Mir war mal wieder etwas langweilig, also hab ich mal schnell das hier gecodet ^^

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    #include <GUIConstantsEx.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Morsecode", 230, 380, -1, -1)
    GUISetBkColor(0xC0DCC0)
    $Label1 = GUICtrlCreateLabel("Bitte geben Sie hier den Text ein.", 4, 4, 219, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit1 = GUICtrlCreateEdit("", 4, 24, 221, 129)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("In Morsecode umwanden", 4, 156, 135, 25, 0)
    $Button2 = GUICtrlCreateButton("Abspielen", 4, 352, 85, 25, 0)
    $Label2 = GUICtrlCreateLabel("Hier steht der Morsecode", 4, 200, 162, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit2 = GUICtrlCreateEdit("", 4, 221, 221, 129)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $Read1 = GUICtrlRead ($Edit1)
    _MorseCodeWrite ($Read1, $Edit2)
    Case $Button2
    $Read2 = GUICtrlRead ($Edit2)
    _Beep ($Read2)
    EndSwitch
    WEnd

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

    Func _MorseCodeWrite ($String, $Handle)
    GUICtrlSetData ($Handle, "")
    Local $Split = StringSplit ($String, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = " " Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "| ")
    ElseIf $Split[$i] = "A" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".- ")
    ElseIf $Split[$i] = "B" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "C" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-. ")
    ElseIf $Split[$i] = "D" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "E" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ". ")
    ElseIf $Split[$i] = "F" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-. ")
    ElseIf $Split[$i] = "G" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "H" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".... ")
    ElseIf $Split[$i] = "I" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".. ")
    ElseIf $Split[$i] = "J" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--- ")
    ElseIf $Split[$i] = "K" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.- ")
    ElseIf $Split[$i] = "L" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.. ")
    ElseIf $Split[$i] = "M" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-- ")
    ElseIf $Split[$i] = "N" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "O" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--- ")
    ElseIf $Split[$i] = "P" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--. ")
    ElseIf $Split[$i] = "S" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "... ")
    ElseIf $Split[$i] = "T" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..- ")
    ElseIf $Split[$i] = "U" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..- ")
    ElseIf $Split[$i] = "V" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...- ")
    ElseIf $Split[$i] = "W" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-- ")
    ElseIf $Split[$i] = "X" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-..- ")
    ElseIf $Split[$i] = "Y" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-- ")
    ElseIf $Split[$i] = "Z" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--.. ")
    ElseIf $Split[$i] = "0" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----- ")
    ElseIf $Split[$i] = "1" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".---- ")
    ElseIf $Split[$i] = "2" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..--- ")
    ElseIf $Split[$i] = "3" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...-- ")
    ElseIf $Split[$i] = "4" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "....- ")
    ElseIf $Split[$i] = "5" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..... ")
    ElseIf $Split[$i] = "6" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.... ")
    ElseIf $Split[$i] = "7" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--... ")
    ElseIf $Split[$i] = "8" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---.. ")
    ElseIf $Split[$i] = "9" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----. ")
    ElseIf $Split[$i] = "." Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.-.- ")
    EndIf
    Next
    EndFunc ;==> _MorseCode
    Func _Beep ($Code)
    $Split = StringSplit ($Code, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = "." Then
    Beep (1000, 50)
    Sleep (125)
    ElseIf $Split[$i] = "-" Then
    Beep (1000, 200)
    Sleep (125)
    ElseIf $Split[$i] = " " Then
    Sleep (250)
    ElseIf $Split[$i] = "|" Then
    Beep (200, 200)
    EndIf
    Next
    Sleep (350)
    EndFunc ;==> _Beep

    [/autoit]

    Einfach oben den Text eingeben, dann auf umwandeln und dann auf Abspielen. ^^
    Bin mir sicher, dass man den code noch stark kürzen kann, aber ich wüsste im moment nich genau wie ...

  • du hast ein paar Buchstaben vergessen, habs mal a bissl verbessert, aber nicht getestet, keine Ahnung ob das break funktioniert so wie ich mir das denke :) wenn nicht auskommentieren

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    #include <GUIConstantsEx.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Morsecode", 230, 380, -1, -1)
    GUISetBkColor(0xC0DCC0)
    $Label1 = GUICtrlCreateLabel("Bitte geben Sie hier den Text ein.", 4, 4, 219, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit1 = GUICtrlCreateEdit("", 4, 24, 221, 129)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("In Morsecode umwanden", 4, 156, 135, 25, 0)
    $Button2 = GUICtrlCreateButton("Abspielen", 4, 352, 85, 25, 0)
    $Label2 = GUICtrlCreateLabel("Hier steht der Morsecode", 4, 200, 162, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit2 = GUICtrlCreateEdit("", 4, 221, 221, 129)
    GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $Read1 = GUICtrlRead ($Edit1)
    _MorseCodeWrite ($Read1, $Edit2)
    Case $Button2
    $Read2 = GUICtrlRead ($Edit2)
    _Beep ($Read2)
    EndSwitch
    WEnd

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

    Func _MorseCodeWrite ($String, $Handle)
    $aLetters = {{" ", "| "}, {"A", ".- "}, {"B", "-. "}, {"C", "-.-. "}, {"D", "-. "}, {"E", ". "}, {"F", ".-. "}, {"G", "-. "}, {"H", ".... "}, {"I", ".. "}, {"J", ".--- "}, {"K", "-.- "}, {"L", ".-.. "}, {"M", "-- "}, {"N", "-. "}, {"O", "--- "}, {"P", ".--. "}, {"Q", "--.- "}, {"R", ".-. "}, {"S", "... "}, {"T", "..- "}, {"U", "..- "}, {"V", "...- "}, {"W", ".-- "}, {"X", "-..- "}, {"Y", "-.-- "}, {"Z", "--.. "}, {"0", "----- "}, {"1", ".---- "}, {"2", "..--- "}, {"3", "...-- "}, {"4", "....- "}, {"5", "..... "}, {"6", "-.... "}, {"7", "--... "}, {"8", "---.. "}, {"9", "----. "}, {".", ".-.-.- "}}
    GUICtrlSetData ($Handle, "")
    Local $Split = StringSplit ($String, "")
    For $i = 1 To $Split[0] Step 1
    for $j = 0 To UBound($aLetters)-1
    if($Split[$i] = $aLetters[$j][0]) then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", $aLetters[$j][1])
    break
    endif
    next
    Next
    EndFunc ;==> _MorseCode
    Func _Beep ($Code)
    $Split = StringSplit ($Code, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = "." Then
    Beep (1000, 50)
    Sleep (125)
    ElseIf $Split[$i] = "-" Then
    Beep (1000, 200)
    Sleep (125)
    ElseIf $Split[$i] = " " Then
    Sleep (250)
    ElseIf $Split[$i] = "|" Then
    Beep (200, 200)
    EndIf
    Next
    Sleep (350)
    EndFunc ;==> _Beep

    [/autoit]

  • sry, da kommt folgende fehlermeldung:

    C:\Dokumente und Einstellungen\Michi\Desktop\Neu AutoIt v3 Script (3).au3 (35) : ==> Unable to parse line.:
    $aLetters = {{" ", "| "}, {"A", ".- "}, {"B", "-. "}, {"C", "-.-. "}, {"D", "-. "}, {"E", ". "}, {"F", ".-. "}, {"G", "-. "}, {"H", ".... "}, {"I", ".. "}, {"J", ".--- "}, {"K", "-.- "}, {"L", ".-.. "}, {"M", "-- "}, {"N", "-. "}, {"O", "--- "}, {"P", ".--. "}, {"Q", "--.- "}, {"R", ".-. "}, {"S", "... "}, {"T", "..- "}, {"U", "..- "}, {"V", "...- "}, {"W", ".-- "}, {"X", "-..- "}, {"Y", "-.-- "}, {"Z", "--.. "}, {"0", "----- "}, {"1", ".---- "}, {"2", "..--- "}, {"3", "...-- "}, {"4", "....- "}, {"5", "..... "}, {"6", "-.... "}, {"7", "--... "}, {"8", "---.. "}, {"9", "----. "}, {".", ".-.-.- "}}
    $aLetters = ^ ERROR
    >Exit code: 1 Time: 0.236

  • Zumindest eckige statt runden Klammern.

    peethebee

    ach ja pöses Java -.-

    dann ersetz mal:

    [autoit]

    Func _MorseCodeWrite ($String, $Handle)
    $aLetters = [[" ", "| "], ["A", ".- "], ["B", "-. "], ["C", "-.-. "], ["D", "-. "], ["E", ". "], ["F", ".-. "], ["G", "-. "], ["H", ".... "], ["I", ".. "], ["J", ".--- "], ["K", "-.- "], ["L", ".-.. "], ["M", "-- "], ["N", "-. "], ["O", "--- "], ["P", ".--. "], ["Q", "--.- "], ["R", ".-. "], ["S", "... "], ["T", "..- "], ["U", "..- "], ["V", "...- "], ["W", ".-- "], ["X", "-..- "], ["Y", "-.-- "], ["Z", "--.. "], ["0", "----- "], ["1", ".---- "], ["2", "..--- "], ["3", "...-- "], ["4", "....- "], ["5", "..... "], ["6", "-.... "], ["7", "--... "], ["8", "---.. "], ["9", "----. "], [".", ".-.-.- "]]
    GUICtrlSetData ($Handle, "")
    Local $Split = StringSplit ($String, "")
    For $i = 1 To $Split[0] Step 1
    for $j = 0 To UBound($aLetters)-1
    if($Split[$i] = $aLetters[$j][0]) then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", $aLetters[$j][1])
    ;break
    endif
    next
    Next
    EndFunc ;==> _MorseCode

    [/autoit]
  • So, hier die erweiterte version:

    Beeps sind nun etwas schneller,
    Man kann nun auch "Anfang -> KA [-.-.-]" und "Ende -> KR [.-.-.]" einfügen ( im menu )
    auserdem lassen sich nun auch folgende zeichen einfügen:
    , \ : \ ? \ - \ () \ " \ @ \ =

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    #include <GUIConstantsEx.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Morsecode", 230, 400, -1, -1)
    GUISetBkColor(0xC0DCC0)
    $Label1 = GUICtrlCreateLabel("Bitte geben Sie hier den Text ein.", 4, 4, 219, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit1 = GUICtrlCreateEdit("", 4, 24, 221, 129)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("In Morsecode umwanden", 4, 156, 135, 25, 0)
    $Button2 = GUICtrlCreateButton("Abspielen", 4, 352, 85, 25, 0)
    $Label2 = GUICtrlCreateLabel("Hier steht der Morsecode", 4, 200, 162, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit2 = GUICtrlCreateEdit("", 4, 221, 221, 129)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $Menu = GUICtrlCreateMenu ("Code")
    $Item1 = GUICtrlCreateMenuItem ("Anfang einfügen -> KA [-.-.-]", $Menu)
    $Item2 = GUICtrlCreateMenuItem ("Ende einfügen -> AR [.-.-.]", $Menu)
    $Item3 = GUICtrlCreateMenuItem ("", $Menu)
    $Item4 = GUICTrlCreateMenuItem ("Beenden -> ESC", $Menu)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE, $Item4
    Exit
    Case $Button1
    $Read1 = GUICtrlRead ($Edit1)
    _MorseCodeWrite ($Read1, $Edit2)
    Case $Button2
    $Read2 = GUICtrlRead ($Edit2)
    _Beep ($Read2)
    Case $Item1
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-.- ")
    ControlCommand ($Form1, "", $Edit1, "EditPaste", "KA ")
    Case $Item2
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.-.")
    ControlCommand ($Form1, "", $Edit1, "EditPaste", " AR")
    EndSwitch
    WEnd

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

    Func _MorseCodeWrite ($String, $Handle)
    GUICtrlSetData ($Handle, "")
    Local $Split = StringSplit ($String, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = " " Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "| ")
    ElseIf $Split[$i] = "A" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".- ")
    ElseIf $Split[$i] = "B" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "C" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-. ")
    ElseIf $Split[$i] = "D" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "E" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ". ")
    ElseIf $Split[$i] = "F" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-. ")
    ElseIf $Split[$i] = "G" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "H" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".... ")
    ElseIf $Split[$i] = "I" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".. ")
    ElseIf $Split[$i] = "J" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--- ")
    ElseIf $Split[$i] = "K" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.- ")
    ElseIf $Split[$i] = "L" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.. ")
    ElseIf $Split[$i] = "M" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-- ")
    ElseIf $Split[$i] = "N" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "O" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--- ")
    ElseIf $Split[$i] = "P" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--. ")
    ElseIf $Split[$i] = "Q" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--.- ")
    ElseIf $Split[$i] = "R" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-. ")
    ElseIf $Split[$i] = "S" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "... ")
    ElseIf $Split[$i] = "T" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..- ")
    ElseIf $Split[$i] = "U" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..- ")
    ElseIf $Split[$i] = "V" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...- ")
    ElseIf $Split[$i] = "W" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-- ")
    ElseIf $Split[$i] = "X" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-..- ")
    ElseIf $Split[$i] = "Y" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-- ")
    ElseIf $Split[$i] = "Z" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--.. ")
    ElseIf $Split[$i] = "Ä" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.- ")
    ElseIf $Split[$i] = "Ö" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---. ")
    ElseIf $Split[$i] = "Ü" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..-- ")
    ElseIf $Split[$i] = "0" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----- ")
    ElseIf $Split[$i] = "1" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".---- ")
    ElseIf $Split[$i] = "2" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..--- ")
    ElseIf $Split[$i] = "3" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...-- ")
    ElseIf $Split[$i] = "4" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "....- ")
    ElseIf $Split[$i] = "5" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..... ")
    ElseIf $Split[$i] = "6" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.... ")
    ElseIf $Split[$i] = "7" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--... ")
    ElseIf $Split[$i] = "8" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---.. ")
    ElseIf $Split[$i] = "9" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----. ")
    ElseIf $Split[$i] = "." Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.-.- ")
    ElseIf $Split[$i] = "," Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--..-- ")
    ElseIf $Split[$i] = ":" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---... ")
    ElseIf $Split[$i] = "?" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..--.. ")
    ElseIf $Split[$i] = "-" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-....- ")
    ElseIf $Split[$i] = "(" or $Split[$i] = ")" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.--.- ")
    ElseIf $Split[$i] = '"' Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-..-. ")
    ElseIf $Split[$i] = "@" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--.-. ")
    ElseIf $Split[$i] = "=" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-...- ")
    EndIf
    Next
    EndFunc ;==> _MorseCode
    Func _Beep ($Code)
    $Split = StringSplit ($Code, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = "." Then
    Beep (1000, 50)
    Sleep (75)
    ElseIf $Split[$i] = "-" Then
    Beep (1000, 200)
    Sleep (75)
    ElseIf $Split[$i] = " " Then
    Sleep (250)
    ElseIf $Split[$i] = "|" Then
    Beep (200, 200)
    EndIf
    Next
    Sleep (350)
    EndFunc ;==> _Beep

    [/autoit]

    PS: @leviathan: Bin grad deine version zu kapiern xD

  • .- .-.. ... --- | .. -.-. .... | .-. .. -. -. . | -. .- ... | .--- .- | . -.-. .... ..- | -.-. --- --- .-.. .-.-.- | .- -. . .-. | .. ... ..- | -- --- .-. ... . -. | -. .. -.-. .... ..- | .- ..- ... | -. . -- | .-.. . ..- --.. ..- . -. | .--- .- .... .-. .... ..- -. -. . .-. ..- | ..--.. ..--.. ..--.. ..--..

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    k3mrwmIBHejryPvylQSFieDF5f3VOnk6iLAVBGVhKQegrFuWr3iraNIblLweSW4WgqI0SrRbS7U5jI3sn50R4a15Cthu1bEr

  • mach ich noch ^^

    PS: Alina: beim übersetzen deines codes kam folgendes raus:

    Zitat

    also ich rinne nas ja echu cool. aner isu morsen nichu aus nem leuzuen jahrhunneru

    stimmt da was mit meinem script net oda so?
    Habs im i.net umwandeln lassen...

    Einmal editiert, zuletzt von Commander21 (13. Juni 2009 um 19:52)

  • Alina: Hast du das von Hand geschrieben? Bei mir kommt das raus: "ALSO ICH RINNE NAS JA ECHU COOL. ANER ISU MORSEN NICHU AUS NEM LEUZUEN JAHRHUNNERU ???? "
    //Edit: nö, das sind einfach falsche Codes im Programm ;) z.B. B = D = -.

    Einmal editiert, zuletzt von progandy (13. Juni 2009 um 19:54)

  • Sry, ein paar Zeilen waren falsch, jetz stimmt alles:

    Spoiler anzeigen
    [autoit]

    #include <Misc.au3>
    #include <GUIConstantsEx.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Morsecode", 230, 400, -1, -1)
    GUISetBkColor(0xC0DCC0)
    $Label1 = GUICtrlCreateLabel("Bitte geben Sie hier den Text ein.", 4, 4, 219, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit1 = GUICtrlCreateEdit("", 4, 24, 221, 129)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("In Morsecode umwanden", 4, 156, 135, 25, 0)
    $Button2 = GUICtrlCreateButton("Abspielen", 4, 352, 85, 25, 0)
    $Label2 = GUICtrlCreateLabel("Hier steht der Morsecode", 4, 200, 162, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit2 = GUICtrlCreateEdit("", 4, 221, 221, 129)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $Menu = GUICtrlCreateMenu ("Code")
    $Item1 = GUICtrlCreateMenuItem ("Anfang einfügen -> KA [-.-.-]", $Menu)
    $Item2 = GUICtrlCreateMenuItem ("Ende einfügen -> AR [.-.-.]", $Menu)
    $Item3 = GUICtrlCreateMenuItem ("", $Menu)
    $Item4 = GUICTrlCreateMenuItem ("Beenden -> ESC", $Menu)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE, $Item4
    Exit
    Case $Button1
    $Read1 = GUICtrlRead ($Edit1)
    _MorseCodeWrite ($Read1, $Edit2)
    Case $Button2
    $Read2 = GUICtrlRead ($Edit2)
    _Beep ($Read2)
    Case $Item1
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-.- ")
    ControlCommand ($Form1, "", $Edit1, "EditPaste", "KA ")
    Case $Item2
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.-.")
    ControlCommand ($Form1, "", $Edit1, "EditPaste", " AR")
    EndSwitch
    WEnd

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

    Func _MorseCodeWrite ($String, $Handle)
    GUICtrlSetData ($Handle, "")
    Local $Split = StringSplit ($String, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = " " Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "| ")
    ElseIf $Split[$i] = "A" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".- ")
    ElseIf $Split[$i] = "B" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-... ")
    ElseIf $Split[$i] = "C" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-. ")
    ElseIf $Split[$i] = "D" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.. ")
    ElseIf $Split[$i] = "E" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ". ")
    ElseIf $Split[$i] = "F" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..-. ")
    ElseIf $Split[$i] = "G" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--. ")
    ElseIf $Split[$i] = "H" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".... ")
    ElseIf $Split[$i] = "I" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".. ")
    ElseIf $Split[$i] = "J" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--- ")
    ElseIf $Split[$i] = "K" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.- ")
    ElseIf $Split[$i] = "L" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.. ")
    ElseIf $Split[$i] = "M" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-- ")
    ElseIf $Split[$i] = "N" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "O" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--- ")
    ElseIf $Split[$i] = "P" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--. ")
    ElseIf $Split[$i] = "Q" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--.- ")
    ElseIf $Split[$i] = "R" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-. ")
    ElseIf $Split[$i] = "S" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "... ")
    ElseIf $Split[$i] = "T" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "- ")
    ElseIf $Split[$i] = "U" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..- ")
    ElseIf $Split[$i] = "V" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...- ")
    ElseIf $Split[$i] = "W" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-- ")
    ElseIf $Split[$i] = "X" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-..- ")
    ElseIf $Split[$i] = "Y" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-- ")
    ElseIf $Split[$i] = "Z" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--.. ")
    ElseIf $Split[$i] = "Ä" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.- ")
    ElseIf $Split[$i] = "Ö" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---. ")
    ElseIf $Split[$i] = "Ü" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..-- ")
    ElseIf $Split[$i] = "0" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----- ")
    ElseIf $Split[$i] = "1" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".---- ")
    ElseIf $Split[$i] = "2" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..--- ")
    ElseIf $Split[$i] = "3" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...-- ")
    ElseIf $Split[$i] = "4" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "....- ")
    ElseIf $Split[$i] = "5" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..... ")
    ElseIf $Split[$i] = "6" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.... ")
    ElseIf $Split[$i] = "7" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--... ")
    ElseIf $Split[$i] = "8" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---.. ")
    ElseIf $Split[$i] = "9" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----. ")
    ElseIf $Split[$i] = "." Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.-.- ")
    ElseIf $Split[$i] = "," Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--..-- ")
    ElseIf $Split[$i] = ":" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---... ")
    ElseIf $Split[$i] = "?" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..--.. ")
    ElseIf $Split[$i] = "-" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-....- ")
    ElseIf $Split[$i] = "(" or $Split[$i] = ")" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.--.- ")
    ElseIf $Split[$i] = '"' Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-..-. ")
    ElseIf $Split[$i] = "@" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--.-. ")
    ElseIf $Split[$i] = "=" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-...- ")
    EndIf
    Next
    EndFunc ;==> _MorseCode
    Func _Beep ($Code)
    $Split = StringSplit ($Code, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = "." Then
    Beep (1000, 50)
    Sleep (75)
    ElseIf $Split[$i] = "-" Then
    Beep (1000, 200)
    Sleep (75)
    ElseIf $Split[$i] = " " Then
    Sleep (250)
    ElseIf $Split[$i] = "|" Then
    Beep (200, 200)
    EndIf
    Next
    Sleep (350)
    EndFunc ;==> _Beep

    [/autoit]
  • Also als erstes einmal habe ich das programm der offiziellen Norm angepaßt.
    Zwischen worten kommt kein "|", sondern die dreifache Länge eines langen Tons.

    Spoiler anzeigen
    [autoit]


    #include <Misc.au3>
    #include <GUIConstantsEx.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Morsecode", 230, 400, -1, -1)
    GUISetBkColor(0xC0DCC0)
    $Label1 = GUICtrlCreateLabel("Bitte geben Sie hier den Text ein.", 4, 4, 219, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit1 = GUICtrlCreateEdit("", 4, 24, 221, 129)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $Button1 = GUICtrlCreateButton("In Morsecode umwanden", 4, 156, 135, 25, 0)
    $Button2 = GUICtrlCreateButton("Abspielen", 4, 352, 85, 25, 0)
    $Label2 = GUICtrlCreateLabel("Hier steht der Morsecode", 4, 200, 162, 20)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    $Edit2 = GUICtrlCreateEdit("", 4, 221, 221, 129)
    GUICtrlSetFont(-1, 9, 800, 0, "MS Sans Serif")
    $Menu = GUICtrlCreateMenu ("Code")
    $Item1 = GUICtrlCreateMenuItem ("Anfang einfügen -> KA [-.-.-]", $Menu)
    $Item2 = GUICtrlCreateMenuItem ("Ende einfügen -> AR [.-.-.]", $Menu)
    $Item3 = GUICtrlCreateMenuItem ("", $Menu)
    $Item4 = GUICTrlCreateMenuItem ("Beenden -> ESC", $Menu)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE, $Item4
    Exit
    Case $Button1
    $Read1 = GUICtrlRead ($Edit1)
    _MorseCodeWrite ($Read1, $Edit2)
    Case $Button2
    $Read2 = GUICtrlRead ($Edit2)
    _Beep ($Read2)
    Case $Item1
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-.- ")
    ControlCommand ($Form1, "", $Edit1, "EditPaste", "KA ")
    Case $Item2
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.-.")
    ControlCommand ($Form1, "", $Edit1, "EditPaste", " AR")
    EndSwitch
    WEnd

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

    Func _MorseCodeWrite ($String, $Handle)
    GUICtrlSetData ($Handle, "")
    Local $Split = StringSplit ($String, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = " " Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", " ")
    ElseIf $Split[$i] = "A" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".- ")
    ElseIf $Split[$i] = "B" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "C" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-. ")
    ElseIf $Split[$i] = "D" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "E" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ". ")
    ElseIf $Split[$i] = "F" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-. ")
    ElseIf $Split[$i] = "G" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "H" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".... ")
    ElseIf $Split[$i] = "I" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".. ")
    ElseIf $Split[$i] = "J" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--- ")
    ElseIf $Split[$i] = "K" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.- ")
    ElseIf $Split[$i] = "L" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.. ")
    ElseIf $Split[$i] = "M" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-- ")
    ElseIf $Split[$i] = "N" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-. ")
    ElseIf $Split[$i] = "O" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--- ")
    ElseIf $Split[$i] = "P" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--. ")
    ElseIf $Split[$i] = "Q" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--.- ")
    ElseIf $Split[$i] = "R" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-. ")
    ElseIf $Split[$i] = "S" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "... ")
    ElseIf $Split[$i] = "T" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..- ")
    ElseIf $Split[$i] = "U" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..- ")
    ElseIf $Split[$i] = "V" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...- ")
    ElseIf $Split[$i] = "W" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-- ")
    ElseIf $Split[$i] = "X" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-..- ")
    ElseIf $Split[$i] = "Y" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.-- ")
    ElseIf $Split[$i] = "Z" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--.. ")
    ElseIf $Split[$i] = "Ä" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.- ")
    ElseIf $Split[$i] = "Ö" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---. ")
    ElseIf $Split[$i] = "Ü" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..-- ")
    ElseIf $Split[$i] = "0" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----- ")
    ElseIf $Split[$i] = "1" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".---- ")
    ElseIf $Split[$i] = "2" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..--- ")
    ElseIf $Split[$i] = "3" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "...-- ")
    ElseIf $Split[$i] = "4" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "....- ")
    ElseIf $Split[$i] = "5" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..... ")
    ElseIf $Split[$i] = "6" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.... ")
    ElseIf $Split[$i] = "7" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--... ")
    ElseIf $Split[$i] = "8" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---.. ")
    ElseIf $Split[$i] = "9" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "----. ")
    ElseIf $Split[$i] = "." Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-.-.- ")
    ElseIf $Split[$i] = "," Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "--..-- ")
    ElseIf $Split[$i] = ":" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "---... ")
    ElseIf $Split[$i] = "?" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "..--.. ")
    ElseIf $Split[$i] = "-" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-....- ")
    ElseIf $Split[$i] = "(" or $Split[$i] = ")" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-.--.- ")
    ElseIf $Split[$i] = '"' Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".-..-. ")
    ElseIf $Split[$i] = "@" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", ".--.-. ")
    ElseIf $Split[$i] = "=" Then
    ControlCommand ($Form1, "", $Edit2, "EditPaste", "-...- ")
    EndIf
    Next
    EndFunc ;==> _MorseCode
    Func _Beep ($Code)
    $Split = StringSplit ($Code, "")
    For $i = 1 To $Split[0] Step 1
    If $Split[$i] = "." Then
    Beep (1000, 50)
    Sleep (75)
    ElseIf $Split[$i] = "-" Then
    Beep (1000, 200)
    Sleep (75)
    ElseIf $Split[$i] = " " Then
    Sleep (250)
    ElseIf $Split[$i] = " " Then
    Beep (200, 200)
    EndIf
    Next
    Sleep (350)
    EndFunc ;==> _Beep

    [/autoit]

    Commander21 Beitrag von 20:03 ist dabei noch nicht beachtet !!!


    In DK morste man in englisch, aber hier mal etwas auf dansk, soweit es möglich ist:
    -. . .-. . .-. ..- . .-. ..- .- -. . . -. .... .. .-.. ... . -. .--. .- . -. .- -. ... -.-

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    k3mrwmIBHejryPvylQSFieDF5f3VOnk6iLAVBGVhKQegrFuWr3iraNIblLweSW4WgqI0SrRbS7U5jI3sn50R4a15Cthu1bEr

  • Wenn man es aufschreibt, kommt schon ein Slash nach dem Wortende. Und beim Abspielen muss man das dann in 7 * Länge kurzer Ton anpassen. (by Wikipedia)

  • .- .-.. ... --- / .. -.-. .... / ..-. .. -. -.. . / -.. . -. / -- --- .-. ... . -.-. --- -.. . .-. / . -.-. .... - / --. ..- - / -.. .- ... / .. ... - / . -.-. .... - / . .. -. . / --. ..- - . / ... .- -.-. .... . ;)

    MfG
    Conan (Nur Mitlesend)
    Schon lange dabei