Computer Hope

Microsoft => Microsoft DOS => Topic started by: Boozu on September 18, 2009, 03:01:29 AM

Title: Batch sounds.
Post by: Boozu on September 18, 2009, 03:01:29 AM
I want to make simple beeps and boops in a batch program withought having to call a audio file. Is there any way to do that? I want it so I can output Morse code. Why? Just because it would be cool.
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 03:16:20 AM
You can write ECHO followed by ALT+7. (on the number pad).  On my system I can write ^G (control+G), and it does the same thing.

Code: [Select]
ECHO ^G
Two-Eyes %

EDIT: but that is only one sound...
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 03:23:23 AM
That did absolutely nothing. Anything else?
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 03:26:41 AM
what did you do exactly?
Title: Re: Batch sounds.
Post by: gpl on September 18, 2009, 03:45:38 AM
For morse, you would be restricted to dahs only !
At least in the UK you could spell MOT (and TOM)
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 04:03:21 AM
Two-eyes: I did echo "^G" "alt+7" and "•" <The symbol derived from pressing alt and then 7. I got no change at all.

gpl: If by dahs you mean a short beeps then that is not a big deal. If there is no way to lengthen the duration of the sound then I will do something like this with the beeps.   . . . ... ... ... . . .   Basically putting a distinguishable pause in bitween a single beep and a line of beeps.
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 04:10:40 AM
I see.  When i press alt+7 it shows "^G".  In your case, it shows that dot.
Well, i know that 7 is the ascii code for the bell..... I'm sorry, but I don't know why it isn't working for you.  Be sure you press the number pad's 7 (although I bet you did, cos the dot was shown).

Try control+G and see what happens.

Two-Eyes %
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 04:26:21 AM
That did not work but on the ascii table (I just learned about this thing this afternoon, haha) under Oct it says 007. I tried that and I immediately heard a ding but it did not put out a symbol in the batch file so I tried alt+007 but nothing happend. So how can I tell the batch file to do the equivalent of alt+007?
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 05:04:32 AM
Ahhh, I see.  Were you trying in a batch file?  I was trying on the command prompt itself.  When I tried to write alt+7 in a batch file, I couldn't.  Then I tried this:

Code: [Select]
c:\>COPY CON bell.bat
@ECHO off

ECHO [and here I pressed alt+7, and the ^G symbol appeared]
[I pressed ctrl+Z and this symbol appeared: ^Z, then I pressed ENTER]

When I ran the batch file the bell was heard:
Code: [Select]
c:\>bell.bat
[bell was heard]
c:\>

When I open the batch file in notepad, after ECHO, there was a symbol that represents a non-printable character (a box.  Can't paste it here >:().

So what you can do is this:
1) use COPY CON to insert one "bell"
2) open the batch file in notepad(or whatever), and whenever you want to output the sound, copy the symbol and paste it

hope this helped

Two-Eyes %

PS. If you didn't understand anything (which i bet you didn't  ;D...cos, sry, but... I'm that way), just tell me, but please don't curse me to heck  ;)
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 05:09:21 AM
I also, just discovered this:

In the EDIT window, you can press ctrl+p to insert a special character...so you can do this:
ECHO [control+p] [alt+7].  Unfortunately, you can't do that in notepad :(

Two-Eyes %
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 05:33:05 AM
Ok. I am totally lost. What do I have to do? The ctrl+z is paste  and ctrl+p is print so what are thous supposed to do? You said something about not being able to do it in notepad and that you did hear something at one point right? So how do I do that? One more question, when you say ^G and ^Z do you literally mean the "^" symbol and the letter "G" and the same for the other or is the combination supposed to mean something?
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 05:50:45 AM
Ok...very sorry...I need to learn how to communicate.

Quote
The ctrl+z is paste  and ctrl+p is print so what are thous supposed to do?
!!!I was not working in notepad, but in the command prompt!!!

I gave it this command: COPY CON [filename]
and then wrote ECHO [alt+7], ENTER
[ctrl+Z], ENTER
Quote
One more question, when you say ^G and ^Z do you literally mean the "^" symbol and the letter "G" and the same for the other or is the combination supposed to mean something?

no, I didn't mean "^" and "G" but [ctrl+G] and those symbols APPEARED. Same for Z.

Quote
What do I have to do?
So again:
1) in the command prompt do this:
Code: [Select]
C:\>COPY CON bell.bat
@ECHO off

ECHO [alt+7]
[ctrl+Z]

C:\>bell.bat
[sound is heard]
C:\>

2) THEN you can open bell.bat in notepad, and copy the (NEW) symbol as many times as you want, adding pauses, etc.

Quote
You said something about not being able to do it in notepad
Forget that...it was just an extra note. :)

Hope that's better,
Two-Eyes %
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 06:07:02 AM
That is so weird. Manually doing the exact same thing does not work. So I copied it many times and it only gave me one beep but then I did this:
Code: [Select]
@echo off

echo 
echo 
echo 
echo 
pause
echo 
echo 
echo 
echo 
echo 
echo 
echo 
echo 
echo 

And I got 4 beeps and once a button was pressed I got 1 more beep. Funny. Now I will play with pauses insted of making the person running it press a button. Does that make since? Thanks for the help. Once I get it to a point that I like, I will upload the file for you guys to try.
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 06:37:52 AM
It worked for me....  ???

Thanks, looking forward for the program, i suggest you use sleep.exe for pauses, but i don't know if it can part-seconds  :-\

Two-Eyes %
Title: Re: Batch sounds.
Post by: Salmon Trout on September 18, 2009, 06:49:08 AM
i suggest you use sleep.exe for pauses, but i don't know if it can part-seconds

Code: [Select]
C:\>sleep /?
Usage:  sleep      time-to-sleep-in-seconds
        sleep [-m] time-to-sleep-in-milliseconds
        sleep [-c] commited-memory ratio (1%-100%)

There are 1000 milliseconds in 1 second.
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 06:52:01 AM
dangit....didn't come to mind...silly me

Thanks :)
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 06:52:37 AM
Ok well this is how I did a simple s.o.s.
Code: [Select]
@echo off

echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 
echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 
echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 
echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 
PING 1.1.1.1 -n 1 -w 1000 >NUL
echo 

So copy that to a batch file and play it. I hope no problems come up because of the copy past over the web.
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 06:57:04 AM
Thanks for the code :). (but i still don't know how to interpret morse...to Google)

At S.T.:
Code: [Select]
c:\>sleep /?

Arguments are: Sleep <seconds>

www.tricerat.com

Two-Eyes %
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 07:04:17 AM
Well it is supposed to be interpreted as ...---... dot dot dot dash dash dash dot dot dot that is S O S as in I NEAD HELP!!! Even is different countries have a different code I think SOS is the same. I don't think it is any different though. Maby if the language uses non standard English symbols.
Title: Re: Batch sounds.
Post by: Two-eyes on September 18, 2009, 07:15:59 AM
ahhh got it.  I thought that the space between the beeps mattered, but the beeps themselves are the letters.  thanks, looking forward for other :)

Two-Eyes %
Title: Re: Batch sounds.
Post by: Salmon Trout on September 18, 2009, 07:17:37 AM
Thanks for the code :). (but i still don't know how to interpret morse...to Google)

At S.T.:
Code: [Select]
c:\>sleep /?

Arguments are: Sleep <seconds>

www.tricerat.com

Two-Eyes %

There are various programs called "sleep.exe" around on the Web. The one I use is the official Microsoft version in the Windows Server 2003 Resource Kit, available here:

http://www.microsoft.com/Downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en#QuickInfoContainer

Lots of other goodies in the Reskit.

After installation, (as it says in the "Instruction" section on that page, under the list of programs), the programs are located in the %Program Files%\Windows Resource Kits\Tools folder.
Title: Re: Batch sounds.
Post by: Boozu on September 18, 2009, 07:25:39 AM
Salmon Trout (love you name fish fish) that is an add-on more or less and unless all users have it it wont work properly. I like using the dos comands that are built in. The sleep and whatever other comands that are added are nice but then you run into compatibility issues.
Title: Re: Batch sounds.
Post by: TheHoFL on September 18, 2009, 12:39:33 PM
Hmmm... i got the beeping to work. I simply copied the following from the forum post and pasted it into my bat file and saved.

Code: [Select]
echo 

...never mind ... i didn't notice the second page ... it's been a LOOONNG week.  :-[
Title: Re: Batch sounds.
Post by: Helpmeh on September 19, 2009, 08:18:22 AM
Use Ping as an almost replacement to sleep.

Ping localhost -n (time in seconds) -w 1000 > nul
Title: Re: Batch sounds.
Post by: macdad- on September 19, 2009, 09:25:23 AM
^G as I have found can only be added to a Batch file when copy con is used, notepad and EDIT cannot add ^G to a batch.

As far as sending different beep frequencies to the speakers they're a number of ways to do this:

1.Write a VB console app that can accept a frequency and duration that would output(I have one that might work)
2.Use a third-party utility for the job(Heres a good list: Link (http://garbo.uwasa.fi/pc/batchutil.html))

Hope this helps
,Nick(macdad-)
Title: Re: Batch sounds.
Post by: Helpmeh on September 19, 2009, 09:41:33 AM
Echo CTRL+G (shows ^G)> "%userprofile%\Desktop\beep.bat"

Then modify beep.bat to your purposes.
Title: Re: Batch sounds.
Post by: billrich on September 19, 2009, 11:30:22 AM
Echo CTRL+G (shows ^G)> "%userprofile%\Desktop\beep.bat"

Then modify beep.bat to your purposes.

That is pretty good Helpmeh.  Who told you about it?

Why do I get this one error?:
'' is not recognized as an internal or external command, operable program or batch file.

C:\>Echo ^G  >> beep.bat

C:\>Echo ^G  >> beep.bat

C:\>Echo ^G  >> beep.bat

C:\>beep

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>
Title: Re: Batch sounds.
Post by: Salmon Trout on September 19, 2009, 11:46:53 AM
The internal speaker has not been a standard item of PC hardware for some years; it is considered "legacy", like floppy and serial/parallel ports. My little Shuttle and my two Dell Optiplexes don't have them, so if I want beeps I have to play around with WAVs and use external speakers.
Title: Re: Batch sounds.
Post by: BC_Programmer on September 19, 2009, 12:10:51 PM
That is pretty good Helpmeh.  Who told you about it?

Why do I get this one error?:
'' is not recognized as an internal or external command, operable program or batch file.

C:\>Echo ^G  >> beep.bat

C:\>Echo ^G  >> beep.bat

C:\>Echo ^G  >> beep.bat

C:\>beep

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>
'' is not recognized as an internal or external command,
operable program or batch file.

C:\>

but of course! Control-G isn't a valid command.

you could- go this though:

Code: [Select]
echo echo ^G>>test.bat

of course for ^G you press Control-G.

if memory serves it is the ASCII "bell" code, which I was originally intended mostly for printers, which would make the bell to call attention when they needed paper or something of that sort. (although in reality I found DOS had a habit of freezing if the Printer encountered difficulties)

Oops... actually, not printers, but early electric typewriters... well, and printers.
Title: Re: Batch sounds.
Post by: Boozu on September 19, 2009, 12:21:41 PM
billrich: You have to do the ^G through the comand prompt window for it to do anything.

Salmon Trout: the built in one may not be standard but if the pc has any speakers then you will hear something.
Title: Re: Batch sounds.
Post by: Salmon Trout on September 19, 2009, 12:23:38 PM

if memory serves it is the ASCII "bell" code [...] early electric typewriters... well, and printers.

The three letter mnemonic for CTRl-G, ASCII 07, is actually BEL, and it goes right back to teletypewriters (TTY) which predated (any) computers by some decades, although the ASCII code set only superseded Baudot in the 1960s.
Title: Re: Batch sounds.
Post by: billrich on September 19, 2009, 12:25:37 PM
Quote
author=Boozu link=topic=92191.msg623779#msg623779 date=1253384501]
billrich: You have to do the ^G through the comand prompt window for it to do anything.

Billrich wrote:

I was able to hear by running beep.bat on my machine ( see  above post )
Title: Re: Batch sounds.
Post by: Salmon Trout on September 19, 2009, 12:26:48 PM
Salmon Trout: the built in one may not be standard but if the pc has any speakers then you will hear something.

Nope. I don't hear CTRl-Gs through my external speakers linked to the sound card, and never have. I think you may be mistaken?
Title: Re: Batch sounds.
Post by: Boozu on September 19, 2009, 12:34:10 PM
Ya I was. I thought you ment something ells.
Title: Re: Batch sounds.
Post by: Salmon Trout on September 19, 2009, 12:37:56 PM
Ya I was. I thought you ment something ells.

I just tried it & got quite excited in case it would work...  :'(