Jump to content
Sign in to follow this  
monoceres

Morse Code

Recommended Posts

monoceres

Ok this is just for fun, I needed something fun after my last project went down, bad...

This will play A-Z and 0-9 as morse.

Morse Code

Have fun :)

Edited by monoceres

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

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
Valuater

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 :)

Great!!

Ok, no more complaining from me...lol

thx

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
monoceres

Hey Val, I get an error when trying to use the modded code: "The $ESkin_folder" wasn't found".

What to do?


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

Share this post


Link to post
Share on other sites
NewBooty

you gotta get teh ez folder in the topic of ezskin/xskin and then put the var where u have it

Share this post


Link to post
Share on other sites
monoceres

you gotta get teh ez folder in the topic of ezskin/xskin and then put the var where u have it

Ehm what?

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

Share this post


Link to post
Share on other sites
NewBooty

do a forum search 4 ezskin or xskin and get teh skin folder dat comes wit it. and then in da script set da varable to dat folder

Share this post


Link to post
Share on other sites
GtaSpider

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 Froum

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
Valuater

Hey Val, I get an error when trying to use the modded code: "The $ESkin_folder" wasn't found".

What to do?

Use this zip with everything

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
monoceres

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!

Share this post


Link to post
Share on other sites
dansxmods

For some reason the version without the sound files does not have sound for me.

It is because the beep function does not work on my pc for some reason.

Edited by dansxmods

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  

×