Jump to content

morse code using beep function


IchBistTod
 Share

Recommended Posts

YOU MUST COMPILE TO CUI NOT GUI

This script will convert text to morse code then beep it out, showing the beeps(long and short) as it goes.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Matrix.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Res_Comment=Text To Morse Code Converter
#AutoIt3Wrapper_Res_Description=Text To Morse Code Converter
#AutoIt3Wrapper_Res_Fileversion=0.0.0.1
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#NoTrayIcon
if $cmdline[0] <> 0 Then

_MorseCodeToAudio(_stringtomorsecode($cmdlineraw))
Else
    while 1
    _MorseCodeToAudio(_stringtomorsecode(_consoleread(">")))
    wend
    EndIf
Func _stringtomorsecode($string)
    $String = stringSplit($string, "")
    $return = ""
    for $i=1 to $string[0]
        switch $string[$i]
            Case "a"
                $return &=".- "
                Case "b"
$return &="-... "
                Case "c"
$return &="-.-. "
                Case "d"
$return &="-.. "
                Case "e"
$return &=". "
                Case "f"
$return &="..-. "
                Case "g"
$return &="--. "
                Case "h"
$return &=".... "
                Case "i"
$return &=".. "
                Case "j"
$return &=".--- "
                Case "k"
$return &="-.- "
                Case "l"
$return &=".-.. "
                Case "m"
$return &="-- "
                Case "n"
$return &="-. "
                Case "o"
$return &="--- "
                Case "p"
$return &=".--. "
                Case "q"
$return &="--.- "
                Case "r"
$return &=".-. "
                Case "s"
$return &="... "
                Case "t"
$return &="- "
                Case "u"
$return &="..- "
                Case "v"
$return &="...- "
                Case "w"
$return &=".-- "
                Case "x"
$return &="-..- "
                Case "y"
$return &="-.-- "
                Case "z"
$return &="--.. "
                Case "1"
$return &=".---- "
                Case "2"
$return &="..--- "
                Case "3"
$return &="...-- "
                Case "4"
$return &="....- "
                Case "5"
$return &="..... "
                Case "6"
$return &="-.... "
                Case "7"
$return &="--... "
                Case "8"
$return &="---.. "
                Case "9"
$return &="----. "
                Case "0"
$return &="----- "
                Case " "
$return = StringTrimright($return, 1)&"/"


        EndSwitch

    Next
    return $return
endfunc
func _MorseCodeToAudio($code)
    $string =StringSplit($code, "")
    for $i=1 to $string[0]
        $beep = $string[$i]
        switch $beep
            case "."
         ConsoleWrite(".")
            beep(701, 80)
            sleep(80)
        case "-"
            ConsoleWrite("-")
            beep(701, 240)
            sleep(80)
        case " "
            sleep(240)
        case "/"
            ConsoleWrite(" ")
            sleep(560)
        EndSwitch

    Next

EndFunc
Func _consoleread($text)
    $input = ""
    ConsoleWrite(@CRLF & $text)

    $file = FileOpen("con", 4)
    While 1
        $chr = FileRead($file, 1)
        If $chr = @LF Then ExitLoop
        $input = $input & BinaryToString($chr)
    WEnd
    FileClose($file)


    Return StringReplace(StringReplace($input, @LF,""), @CR,"")
EndFunc

[center][/center][center]=][u][/u][/center][center][/center]

Link to comment
Share on other sites

I like it.

I see you have a small glitch around line 118 (or something like that).

You likely meant:

;...
Case " "
                ConsoleWrite(" ")
                Sleep(240)
            Case "/"
                ConsoleWrite(" / ")
                Sleep(560)
        EndSwitch

Right?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

I dont believe so, because i think a / in morse code is a line break, so i think it shoulda been a @LF although im not sure. Wrote it like 2 months ago... :D mess arroudn with it and see what seems right if you wish ad post updated code.

But for me its worked fine as is.

[center][/center][center]=][u][/u][/center][center][/center]

Link to comment
Share on other sites

 I was considering how the fuck you would do that and i thought... im sure its possible somehow.... speaker wire to phone wire or some sh*t liek that, :D

Edited by IchBistTod

[center][/center][center]=][u][/u][/center][center][/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...