How to play a tiny sound everytime there is an output on command prompt












1















Here is a new challenge, I want to make windows 10 command prompt or PowerShell window to play a tiny very short 'tick' sound like they do in the movies, everytime there is a new line printed on the command window, whether it is directly in the command or it is in let's say >>> python environment, I want it to tick, every time there is a new line printed, no matter what application is being run inside the cmd.



The beauty of it all is that you can easily do this in Linux terminals. Any ideas how to do it for Widnows 10?



Thank you folks










share|improve this question


















  • 1





    Just do a search for 'PowerShell play sounds' or 'cmd play sounds', and you'll get a list for that sort of thing.

    – postanote
    Jan 19 at 19:30











  • Thank you @postanote . I have already searched for that stuff, nothing was found that would be useful and practical, which is why I am here asking this question.

    – JackBixuis
    Jan 19 at 19:34
















1















Here is a new challenge, I want to make windows 10 command prompt or PowerShell window to play a tiny very short 'tick' sound like they do in the movies, everytime there is a new line printed on the command window, whether it is directly in the command or it is in let's say >>> python environment, I want it to tick, every time there is a new line printed, no matter what application is being run inside the cmd.



The beauty of it all is that you can easily do this in Linux terminals. Any ideas how to do it for Widnows 10?



Thank you folks










share|improve this question


















  • 1





    Just do a search for 'PowerShell play sounds' or 'cmd play sounds', and you'll get a list for that sort of thing.

    – postanote
    Jan 19 at 19:30











  • Thank you @postanote . I have already searched for that stuff, nothing was found that would be useful and practical, which is why I am here asking this question.

    – JackBixuis
    Jan 19 at 19:34














1












1








1


2






Here is a new challenge, I want to make windows 10 command prompt or PowerShell window to play a tiny very short 'tick' sound like they do in the movies, everytime there is a new line printed on the command window, whether it is directly in the command or it is in let's say >>> python environment, I want it to tick, every time there is a new line printed, no matter what application is being run inside the cmd.



The beauty of it all is that you can easily do this in Linux terminals. Any ideas how to do it for Widnows 10?



Thank you folks










share|improve this question














Here is a new challenge, I want to make windows 10 command prompt or PowerShell window to play a tiny very short 'tick' sound like they do in the movies, everytime there is a new line printed on the command window, whether it is directly in the command or it is in let's say >>> python environment, I want it to tick, every time there is a new line printed, no matter what application is being run inside the cmd.



The beauty of it all is that you can easily do this in Linux terminals. Any ideas how to do it for Widnows 10?



Thank you folks







windows command-line shell powershell cmd.exe






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 19 at 7:03









JackBixuisJackBixuis

3319




3319








  • 1





    Just do a search for 'PowerShell play sounds' or 'cmd play sounds', and you'll get a list for that sort of thing.

    – postanote
    Jan 19 at 19:30











  • Thank you @postanote . I have already searched for that stuff, nothing was found that would be useful and practical, which is why I am here asking this question.

    – JackBixuis
    Jan 19 at 19:34














  • 1





    Just do a search for 'PowerShell play sounds' or 'cmd play sounds', and you'll get a list for that sort of thing.

    – postanote
    Jan 19 at 19:30











  • Thank you @postanote . I have already searched for that stuff, nothing was found that would be useful and practical, which is why I am here asking this question.

    – JackBixuis
    Jan 19 at 19:34








1




1





Just do a search for 'PowerShell play sounds' or 'cmd play sounds', and you'll get a list for that sort of thing.

– postanote
Jan 19 at 19:30





Just do a search for 'PowerShell play sounds' or 'cmd play sounds', and you'll get a list for that sort of thing.

– postanote
Jan 19 at 19:30













Thank you @postanote . I have already searched for that stuff, nothing was found that would be useful and practical, which is why I am here asking this question.

– JackBixuis
Jan 19 at 19:34





Thank you @postanote . I have already searched for that stuff, nothing was found that would be useful and practical, which is why I am here asking this question.

– JackBixuis
Jan 19 at 19:34










1 Answer
1






active

oldest

votes


















3














Playing a sound in PS is as simple as doing this...



# this
"`a"

# or this basic tone
[console]::beep(1000, 500)


Change the value of the first number to alter the pitch (anything lower than 190 or higher than 8500 can’t be heard), and change the value of the second number to alter the duration:



# Or this
[System.Media.SystemSounds]::Beep.Play()


Then tie that to you output code. For external exe in PS you have to code to retrieve output from that, using PS redirection.



Use whatever tool you choose to create the sound you'd want to play. Of course that has to be on all the systems you plan to run your code.



1..3 | %{
'Play a sound'
[console]::beep(1000, 500)
}


Update for OP



No worries.



As for (1) - you should just need to add the sound line before or after the expected text output, as in that shown loop example.

As for (2) it's no where near as flexible. You are limited to using CRTL+G in a .bat/.cmd file and calling that before or after your expected output line.



Yet, again, you'd have to code to trap all the output you are after. Playing wav files, mean calling a media player in your code especially for cmd.exe.



# PowerShell playing a wav file
$PlayWav=New-Object System.Media.SoundPlayer
$PlayWav.SoundLocation='C:FooSoundfile.wav'
$PlayWav.playsync()

# CMD playing a wav file
start 'C:FooSoundfile.wav'


Here's the real issue with play .wav files, or anything outside of the normal console beeps, the media player will be called each time and have to display to play the file and have to be dismissed. Not a very automated thing..



So, IMHO for what you are after stick with the native console sounds.






share|improve this answer


























  • This was superb helped more than you could imagine, but two questions remain: 1- Can I use this to play a tiny wav file, for every line of code that is printed on the output, and 2- How can I do this on the cmd.exe as well?

    – JackBixuis
    Jan 19 at 21:57













  • See my update for you.

    – postanote
    Jan 20 at 4:17











  • Thank you. I was mostly looking for an automated way. Like the shell or cmd playing a tiny tune all by itself, and on every output line, not only on a designated place. More like an audio template for cmd or PS, that every time there is an activity of the window of terminal, it would play a tiny little bleep. Kind of like what command prompts sound like in Hollywood movies.

    – JackBixuis
    Jan 21 at 1:06











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1396010%2fhow-to-play-a-tiny-sound-everytime-there-is-an-output-on-command-prompt%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Playing a sound in PS is as simple as doing this...



# this
"`a"

# or this basic tone
[console]::beep(1000, 500)


Change the value of the first number to alter the pitch (anything lower than 190 or higher than 8500 can’t be heard), and change the value of the second number to alter the duration:



# Or this
[System.Media.SystemSounds]::Beep.Play()


Then tie that to you output code. For external exe in PS you have to code to retrieve output from that, using PS redirection.



Use whatever tool you choose to create the sound you'd want to play. Of course that has to be on all the systems you plan to run your code.



1..3 | %{
'Play a sound'
[console]::beep(1000, 500)
}


Update for OP



No worries.



As for (1) - you should just need to add the sound line before or after the expected text output, as in that shown loop example.

As for (2) it's no where near as flexible. You are limited to using CRTL+G in a .bat/.cmd file and calling that before or after your expected output line.



Yet, again, you'd have to code to trap all the output you are after. Playing wav files, mean calling a media player in your code especially for cmd.exe.



# PowerShell playing a wav file
$PlayWav=New-Object System.Media.SoundPlayer
$PlayWav.SoundLocation='C:FooSoundfile.wav'
$PlayWav.playsync()

# CMD playing a wav file
start 'C:FooSoundfile.wav'


Here's the real issue with play .wav files, or anything outside of the normal console beeps, the media player will be called each time and have to display to play the file and have to be dismissed. Not a very automated thing..



So, IMHO for what you are after stick with the native console sounds.






share|improve this answer


























  • This was superb helped more than you could imagine, but two questions remain: 1- Can I use this to play a tiny wav file, for every line of code that is printed on the output, and 2- How can I do this on the cmd.exe as well?

    – JackBixuis
    Jan 19 at 21:57













  • See my update for you.

    – postanote
    Jan 20 at 4:17











  • Thank you. I was mostly looking for an automated way. Like the shell or cmd playing a tiny tune all by itself, and on every output line, not only on a designated place. More like an audio template for cmd or PS, that every time there is an activity of the window of terminal, it would play a tiny little bleep. Kind of like what command prompts sound like in Hollywood movies.

    – JackBixuis
    Jan 21 at 1:06
















3














Playing a sound in PS is as simple as doing this...



# this
"`a"

# or this basic tone
[console]::beep(1000, 500)


Change the value of the first number to alter the pitch (anything lower than 190 or higher than 8500 can’t be heard), and change the value of the second number to alter the duration:



# Or this
[System.Media.SystemSounds]::Beep.Play()


Then tie that to you output code. For external exe in PS you have to code to retrieve output from that, using PS redirection.



Use whatever tool you choose to create the sound you'd want to play. Of course that has to be on all the systems you plan to run your code.



1..3 | %{
'Play a sound'
[console]::beep(1000, 500)
}


Update for OP



No worries.



As for (1) - you should just need to add the sound line before or after the expected text output, as in that shown loop example.

As for (2) it's no where near as flexible. You are limited to using CRTL+G in a .bat/.cmd file and calling that before or after your expected output line.



Yet, again, you'd have to code to trap all the output you are after. Playing wav files, mean calling a media player in your code especially for cmd.exe.



# PowerShell playing a wav file
$PlayWav=New-Object System.Media.SoundPlayer
$PlayWav.SoundLocation='C:FooSoundfile.wav'
$PlayWav.playsync()

# CMD playing a wav file
start 'C:FooSoundfile.wav'


Here's the real issue with play .wav files, or anything outside of the normal console beeps, the media player will be called each time and have to display to play the file and have to be dismissed. Not a very automated thing..



So, IMHO for what you are after stick with the native console sounds.






share|improve this answer


























  • This was superb helped more than you could imagine, but two questions remain: 1- Can I use this to play a tiny wav file, for every line of code that is printed on the output, and 2- How can I do this on the cmd.exe as well?

    – JackBixuis
    Jan 19 at 21:57













  • See my update for you.

    – postanote
    Jan 20 at 4:17











  • Thank you. I was mostly looking for an automated way. Like the shell or cmd playing a tiny tune all by itself, and on every output line, not only on a designated place. More like an audio template for cmd or PS, that every time there is an activity of the window of terminal, it would play a tiny little bleep. Kind of like what command prompts sound like in Hollywood movies.

    – JackBixuis
    Jan 21 at 1:06














3












3








3







Playing a sound in PS is as simple as doing this...



# this
"`a"

# or this basic tone
[console]::beep(1000, 500)


Change the value of the first number to alter the pitch (anything lower than 190 or higher than 8500 can’t be heard), and change the value of the second number to alter the duration:



# Or this
[System.Media.SystemSounds]::Beep.Play()


Then tie that to you output code. For external exe in PS you have to code to retrieve output from that, using PS redirection.



Use whatever tool you choose to create the sound you'd want to play. Of course that has to be on all the systems you plan to run your code.



1..3 | %{
'Play a sound'
[console]::beep(1000, 500)
}


Update for OP



No worries.



As for (1) - you should just need to add the sound line before or after the expected text output, as in that shown loop example.

As for (2) it's no where near as flexible. You are limited to using CRTL+G in a .bat/.cmd file and calling that before or after your expected output line.



Yet, again, you'd have to code to trap all the output you are after. Playing wav files, mean calling a media player in your code especially for cmd.exe.



# PowerShell playing a wav file
$PlayWav=New-Object System.Media.SoundPlayer
$PlayWav.SoundLocation='C:FooSoundfile.wav'
$PlayWav.playsync()

# CMD playing a wav file
start 'C:FooSoundfile.wav'


Here's the real issue with play .wav files, or anything outside of the normal console beeps, the media player will be called each time and have to display to play the file and have to be dismissed. Not a very automated thing..



So, IMHO for what you are after stick with the native console sounds.






share|improve this answer















Playing a sound in PS is as simple as doing this...



# this
"`a"

# or this basic tone
[console]::beep(1000, 500)


Change the value of the first number to alter the pitch (anything lower than 190 or higher than 8500 can’t be heard), and change the value of the second number to alter the duration:



# Or this
[System.Media.SystemSounds]::Beep.Play()


Then tie that to you output code. For external exe in PS you have to code to retrieve output from that, using PS redirection.



Use whatever tool you choose to create the sound you'd want to play. Of course that has to be on all the systems you plan to run your code.



1..3 | %{
'Play a sound'
[console]::beep(1000, 500)
}


Update for OP



No worries.



As for (1) - you should just need to add the sound line before or after the expected text output, as in that shown loop example.

As for (2) it's no where near as flexible. You are limited to using CRTL+G in a .bat/.cmd file and calling that before or after your expected output line.



Yet, again, you'd have to code to trap all the output you are after. Playing wav files, mean calling a media player in your code especially for cmd.exe.



# PowerShell playing a wav file
$PlayWav=New-Object System.Media.SoundPlayer
$PlayWav.SoundLocation='C:FooSoundfile.wav'
$PlayWav.playsync()

# CMD playing a wav file
start 'C:FooSoundfile.wav'


Here's the real issue with play .wav files, or anything outside of the normal console beeps, the media player will be called each time and have to display to play the file and have to be dismissed. Not a very automated thing..



So, IMHO for what you are after stick with the native console sounds.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 20 at 4:18

























answered Jan 19 at 19:55









postanotepostanote

1,01833




1,01833













  • This was superb helped more than you could imagine, but two questions remain: 1- Can I use this to play a tiny wav file, for every line of code that is printed on the output, and 2- How can I do this on the cmd.exe as well?

    – JackBixuis
    Jan 19 at 21:57













  • See my update for you.

    – postanote
    Jan 20 at 4:17











  • Thank you. I was mostly looking for an automated way. Like the shell or cmd playing a tiny tune all by itself, and on every output line, not only on a designated place. More like an audio template for cmd or PS, that every time there is an activity of the window of terminal, it would play a tiny little bleep. Kind of like what command prompts sound like in Hollywood movies.

    – JackBixuis
    Jan 21 at 1:06



















  • This was superb helped more than you could imagine, but two questions remain: 1- Can I use this to play a tiny wav file, for every line of code that is printed on the output, and 2- How can I do this on the cmd.exe as well?

    – JackBixuis
    Jan 19 at 21:57













  • See my update for you.

    – postanote
    Jan 20 at 4:17











  • Thank you. I was mostly looking for an automated way. Like the shell or cmd playing a tiny tune all by itself, and on every output line, not only on a designated place. More like an audio template for cmd or PS, that every time there is an activity of the window of terminal, it would play a tiny little bleep. Kind of like what command prompts sound like in Hollywood movies.

    – JackBixuis
    Jan 21 at 1:06

















This was superb helped more than you could imagine, but two questions remain: 1- Can I use this to play a tiny wav file, for every line of code that is printed on the output, and 2- How can I do this on the cmd.exe as well?

– JackBixuis
Jan 19 at 21:57







This was superb helped more than you could imagine, but two questions remain: 1- Can I use this to play a tiny wav file, for every line of code that is printed on the output, and 2- How can I do this on the cmd.exe as well?

– JackBixuis
Jan 19 at 21:57















See my update for you.

– postanote
Jan 20 at 4:17





See my update for you.

– postanote
Jan 20 at 4:17













Thank you. I was mostly looking for an automated way. Like the shell or cmd playing a tiny tune all by itself, and on every output line, not only on a designated place. More like an audio template for cmd or PS, that every time there is an activity of the window of terminal, it would play a tiny little bleep. Kind of like what command prompts sound like in Hollywood movies.

– JackBixuis
Jan 21 at 1:06





Thank you. I was mostly looking for an automated way. Like the shell or cmd playing a tiny tune all by itself, and on every output line, not only on a designated place. More like an audio template for cmd or PS, that every time there is an activity of the window of terminal, it would play a tiny little bleep. Kind of like what command prompts sound like in Hollywood movies.

– JackBixuis
Jan 21 at 1:06


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1396010%2fhow-to-play-a-tiny-sound-everytime-there-is-an-output-on-command-prompt%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

Eduardo VII do Reino Unido