0

So I am trying to teach myself C++ and at the moment I am working on creating a sort of piano, using the Beep-function in Windows.

I am wondering how to make the beep last for as long as I press the keys on the keyboard. Doing a bit of research online I found something called _IsPressed which I can't get to work because I don't know how to include <Misc.au3> (it gives an error, saying "no such file or directory" which makes me wonder if I have to download and install something first).

As you may suspect, I am very much a beginner. Does anyone have any helpful tips?

  • 2
    Do you mean [this](https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277%28v=vs.85%29.aspx) function? – Codor Jun 12 '15 at 14:05
  • related: http://stackoverflow.com/questions/4060601/make-sounds-beep-with-c – NathanOliver Jun 12 '15 at 14:05
  • Yes! Beep() with parameters frequency and duration. – VincentVance Jun 12 '15 at 14:08
  • Normally, you'd create a window and then it's straightforward to get key presses sent to it. If you have to do it without a window, then hooks are normally used. – chris Jun 12 '15 at 14:08
  • 2
    Advice: don't mix up "learning C++" (where there is no such thing as a "Beep" function), and learning to use some API (Windows, I assume, although it is not stated in the question). – kebs Jun 12 '15 at 14:13
  • The problem here is you have no idea how long the user will press the key, and you have to know how long to make the sound for when you call `Beep()`. What you need is a "start beeping" and "stop beeping" function, which `Beep()` doesn't do. – Steve Jun 12 '15 at 18:40

0 Answers0