ASCII character code 0x07 is a beep character.
Opening CMD and clicking ALT + 007 yields :
And when I click ENTER - I hear a beep. This is fine.
I've searched how to add a beep in the end of a batch file, and I found that this is the solution : (I'm pasting it as an image becuase SO doesn't show the round bullet after editing) :
This does work and does make a sound. When examined with a HEX viewer (with beyond compare) on ECHO
, the round bullet is:
But if I manually add ALT+7 to the document , I see this:
Which is a 95 as a hex - and it's not a Beep. In addition, I went to the working batch file and added a new line with my ALT+7 :
But looking via HEX viewer :
Question:
I'm a bit confused. Clicking Alt+65 does yields A
everywhere.
So why does the beep different and doesn't work when saved in Windows GUI?
In the console, if I click ALT+007
I get ^G
(it does beep), but when I click ALT+7
I get the circle, which is not a beep:
Here are both:
Another interesting observation via notepad++ :
I think it's related to encoding, etc, but I don't understand the inconsistency.
I have a workaround to suggest. Put this in your script:
forfiles /p "%~dp0" /m "%~nx0" /c "cmd /c echo 0x07"
For every file in your script's directory matching your script's filename (e.g. 1 time), it will echo ASCII character 7, and will make noise. From the forfiles /?
documentation:
To include special characters in the command line, use the hexadecimal code for the character in 0xHH format (ex. 0x09 for tab). Internal CMD.exe commands should be preceded with "cmd /c".
forfiles
is a handy utility to abuse whenever you need a non-printable or extended character.
As for my speculation for why Alt+007 doesn't behave as expected, I believe the console works on a different codepage from windowed applications (console = 437, windowed = 1252 for en-US, IIRC). I've struggled with this issue as well for reasons, ultimately resorting to hard coding the symbols used for console characters 1 through 31 in that JavaScript project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With