Jump to content

Morse Code


 Share

Recommended Posts

Really Cool!!!

It seemed to run a bit quickly and hard to tell which letter/number was being heard while the highlighted text was moving. maybe a small sleep in the loop would fix that...

Else
                _SoundPlay($chars[$i] & "_morse_code.wav", 1)
                _SoundSeek($chars[$i] & "_morse_code.wav", 0, 0, 0)
                ConsoleWrite($i & @CRLF)
                Sleep(200)
            EndIf

... that number might need adjusting

Thanks for sharing

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Really Cool!!!

It seemed to run a bit quickly and hard to tell which letter/number was being heard while the highlighted text was moving. maybe a small sleep in the loop would fix that...

Else
                _SoundPlay($chars[$i] & "_morse_code.wav", 1)
                _SoundSeek($chars[$i] & "_morse_code.wav", 0, 0, 0)
                ConsoleWrite($i & @CRLF)
                Sleep(200)
            EndIf

... that number might need adjusting

Thanks for sharing

8)

Actually there should be a sleep of 270 ms there, (3 small beeps of silence), just forgot to add it :(

Thanks for noticing :)

Edit: Updated first post

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

This really interested me because I don't know Morse Code. I would really like to know how to "do" SOS. However, in your script it actually plays 4 sounds and that is confusing me a little. I see

0

1

2

3

Is that correct?

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

This really interested me because I don't know Morse Code. I would really like to know how to "do" SOS. However, in your script it actually plays 4 sounds and that is confusing me a little. I see

0

1

0

3

Is that correct?

8)

I really don't know, I just read the wiki site, and downloaded the sounds there.

Here's the link :)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Now I see the error, I start with element 0 in my array, and since I use StringSplit that is how many number I have.

Uploading fixed version :)

Edit: Done, fixed version on top

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Ok, no more complaining from me...lol

8)

How about a positive visual addition

Posted Image

heres the code....

#region ; Code generated by EzSkin_1-2-3, Created by Valuater
; For personal use only, All Rights Reserved
; Author of this code: Valuater
; Thank you big_daddy and Joscpe
#include <EzSkin.au3>

; Author monoceres, source wikipedia
#include <Sound.au3>
#include <File.au3>
#include <GuiEdit.au3>
#include <EditConstants.au3>

Opt("GUIOnEventMode", 1)

Global $run = False
Global $string

$files = _FileListToArray("morse_sound", "*.wav")
Dim $sounds[UBound($files) - 1]

For $i = 0 To UBound($sounds) - 1
    $sounds[$i] = _SoundOpen("morse_sound\" & $files[$i], $files[$i])
Next

$EzGUI = EzSkinGUICreate ("MyEzSkinDemo", 500, 300)
$EzIcon = EzSkinIcon ($EzGUI)
GUICtrlSetOnEvent($EzIcon[1], "close")
GUICtrlSetOnEvent($EzIcon[2], "mini")

$edit = _GUICtrlEdit_Create ($EzGUI, "Sample text", 60, 60, 380, 140, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_MULTILINE))

$Button = EzSkinButton ("Start", 210, 210, 80, 25)
GUICtrlSetOnEvent($Button, "start")


GUISetState()

While 1
    EzSkinOver ()
    
    If Not $run Then
        Sleep(50)
    Else
        $chars = StringSplit($string, "")
        For $i = 1 To UBound($chars) - 1
            _GUICtrlEdit_SetSel ($edit, $i - 1, $i)
            If $chars[$i] = " "  Or $chars[$i] = @CR Or $chars[$i] = @LF Then
                Sleep(360)
            Else
                _SoundPlay($chars[$i] & "_morse_code.wav", 1)
                _SoundSeek($chars[$i] & "_morse_code.wav", 0, 0, 0)
                Sleep(270)
            EndIf
        Next
        $run = False
        _GUICtrlEdit_SetSel ($edit, 0, 0)
    EndIf

WEnd

Func start()
    $string = StringUpper(_GUICtrlEdit_GetText ($edit))
    $run = True
    ControlClick("Morse Code", "", $edit)
EndFunc   ;==>start

Func close()
    Exit
EndFunc   ;==>close

Func mini()
    GUISetState(@SW_MINIMIZE, $EzGUI)
EndFunc   ;==>mini


#endregion

All thats needed is EzSkin....

http://www.autoitscript.com/forum/index.ph...st&p=307380

8)

NEWHeader1.png

Link to comment
Share on other sites

Cool :)

Never heard of EzSkin before looks great :(

Especially the button looks cool.

This turned out to be a great way of learning morse btw. Better than I expected.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Hi

Nice Script :)

But its bad, that you had to play soundfiles. They are too big..

Here is a Code with the function "Beep":

#include<GuiEdit.au3>
#include<EditConstants.au3>
#include<GUIConstantsEx.au3>
; Author monoceres and GtaSpider, source wikipedia
Opt("GUIOnEventMode", 1)
Global $run = False,$string
$win = GUICreate("Morse Code", 400, 200)
$edit = _GUICtrlEdit_Create($win, "SOS", 10, 10, 380, 140, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_MULTILINE))
$hStart = GUICtrlCreateButton("Start", 180, 160, 40, 25)
GUICtrlSetOnEvent(-1, "start")
GUISetOnEvent(-3, "close")
GUISetState()
While 1
    If Not $run Then
        Sleep(50)
    Else
        GUICtrlSetState($hStart,$GUI_DISABLE)
        $chars = StringSplit($string, "")
        For $i = 1 To UBound($chars) - 1
            _GUICtrlEdit_SetSel($edit, $i - 1, $i)
            If $chars[$i] = " " Or $chars[$i] = @CR Or $chars[$i] = @LF Then
                Sleep(360)
            Else
                _PlayMorse($chars[$i])
                Sleep(270)
            EndIf
        Next
        GUICtrlSetState($hStart,$GUI_ENABLE)
        GUICtrlSetData($hStart,"Start")
        $run = False
        _GUICtrlEdit_SetSel($edit, 0, 0)
    EndIf
WEnd
Func start()
    $string = StringUpper(_GUICtrlEdit_GetText($edit))
    $run = True
    ControlClick("Morse Code", "", $edit)
EndFunc   ;==>start
Func close()
    Exit
EndFunc   ;==>close
Func _PlayMorse($sChar)
    Local $aSS = StringSplit(FileRead("Morse.audb"), @CRLF,1), $i, $sMorse
    For $i = 1 To $aSS[0]
        If StringLeft($aSS[$i], 1) = $sChar Then $sMorse = StringTrimLeft($aSS[$i], 1)
    Next
    If Not StringLen($sMorse) Then Return 0
    GUICtrlSetData($hStart,$sMorse)
    $aSS = StringSplit($sMorse, "")
    For $i = 1 To $aSS[0]
        If $aSS[$i] = "." Then
            $iDealy = 250
        Else
            $iDealy = 250*2
        EndIf
        Beep(600,$iDealy)
        Sleep(10)
    Next
EndFunc

All what you need is the file "Morse.audb". Its in the Attachment in the ZIP!

Your Spider

Morse_Code_500x_smaler___ReUPP_by_Spider.zip

www.AutoIt.de - Moderator of the German AutoIt Forum

 

Link to comment
Share on other sites

Hi

Nice Script :)

But its bad, that you had to play soundfiles. They are too big..

Here is a Code with the function "Beep":

#include<GuiEdit.au3>
#include<EditConstants.au3>
#include<GUIConstantsEx.au3>
; Author monoceres and GtaSpider, source wikipedia
Opt("GUIOnEventMode", 1)
Global $run = False,$string
$win = GUICreate("Morse Code", 400, 200)
$edit = _GUICtrlEdit_Create($win, "SOS", 10, 10, 380, 140, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_MULTILINE))
$hStart = GUICtrlCreateButton("Start", 180, 160, 40, 25)
GUICtrlSetOnEvent(-1, "start")
GUISetOnEvent(-3, "close")
GUISetState()
While 1
    If Not $run Then
        Sleep(50)
    Else
        GUICtrlSetState($hStart,$GUI_DISABLE)
        $chars = StringSplit($string, "")
        For $i = 1 To UBound($chars) - 1
            _GUICtrlEdit_SetSel($edit, $i - 1, $i)
            If $chars[$i] = " " Or $chars[$i] = @CR Or $chars[$i] = @LF Then
                Sleep(360)
            Else
                _PlayMorse($chars[$i])
                Sleep(270)
            EndIf
        Next
        GUICtrlSetState($hStart,$GUI_ENABLE)
        GUICtrlSetData($hStart,"Start")
        $run = False
        _GUICtrlEdit_SetSel($edit, 0, 0)
    EndIf
WEnd
Func start()
    $string = StringUpper(_GUICtrlEdit_GetText($edit))
    $run = True
    ControlClick("Morse Code", "", $edit)
EndFunc   ;==>start
Func close()
    Exit
EndFunc   ;==>close
Func _PlayMorse($sChar)
    Local $aSS = StringSplit(FileRead("Morse.audb"), @CRLF,1), $i, $sMorse
    For $i = 1 To $aSS[0]
        If StringLeft($aSS[$i], 1) = $sChar Then $sMorse = StringTrimLeft($aSS[$i], 1)
    Next
    If Not StringLen($sMorse) Then Return 0
    GUICtrlSetData($hStart,$sMorse)
    $aSS = StringSplit($sMorse, "")
    For $i = 1 To $aSS[0]
        If $aSS[$i] = "." Then
            $iDealy = 250
        Else
            $iDealy = 250*2
        EndIf
        Beep(600,$iDealy)
        Sleep(10)
    Next
EndFunc

All what you need is the file "Morse.audb". Its in the Attachment in the ZIP!

Your Spider

This is exactly like open source should work, everyone making improvements :(

I actually thought of beeping the morse but I cannot stand the sound, I gave a friend the super mario beep song and he looped it and played it for hoooours on a LAN we went on :D

Maybe make a compromise with only two sound files, long and short?

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Use this zip with everything

8)

Thanks, but I noticed that the highlightning was gone, why is that?

Edit: Nevermind it was because you changed the title of the window

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

  • 6 months later...
  • 13 years later...
  • Moderators

roseramms,

Welcome to the AutoIt forums.

But I feel you would be better served by asking this question on an amateur radio forum as I am not sure many here will have had any experience of using Morse code "for real". In my own case, I had to learn it to identify radio beacons - but most of the time you already knew the code you expected to hear and by definition the code repeated at regular intervals - although I seem to remember that the exam only repeated the code once (it was nearly 50 years ago)!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...