Sign in to follow this  
Followers 0
IchBistTod

morse code using beep function

13 posts in this topic

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]

Share this post


Link to post
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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

How am I supposed to compile this? Because #AutoIt3Wrapper_Change2CUI=y

gives an error: Invalid Compiler directive

Share this post


Link to post
Share on other sites

make sure you have the latest scite, and autoit, and chose to compile with options. that should compile it to a command line app, which is required.


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

Share this post


Link to post
Share on other sites

Both 3.3.0.0 and the beta version 3.3.1.1 won't compile it to console.

It does compile to console.

Open Aut2Exe v3, Browse for source file location. Tick the Console? checkbox and press Convert.

Share this post


Link to post
Share on other sites

Reminds me of the movie Transformers where they use a old computer to send morse codes to the ministry of defence. : )

that was my inspiration. lol :D


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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Haha, very good! I guess it can work, you just attach a cable to the whatever controls the computer speaker and you're done. : )

Edited by Manadar

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

 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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0