I want to make my computer beep, when a specific file I have already created changes. The idea is this:
I have a personalized e-mail for my website.
When people send me a message, I don't know what happens at all, but at least I can create a file which leaves the comment there. How can I make a program to beep when a file changes?
If it's a console program (it shouldn't be), then you can output char(7) and on most systems (not all) it will beep.
Generally though you should either play a sound file, which involves using a sound library or multimedia library. Since your application shouldn't be a console application I'm assuming you're already using a multimedia library like SFML to display your application interface. Therefore it should be simple to play e.g. Beep.ogg
It is a combination of php and C++
I get the info from php and I want to create a little program which will run on screen all the time, wherever the file changes. I want it to beep, I don't care what kind of sound it is, so there is no big deal with the library.
When people send me a message, I don't know what happens at all...
This part worries me a bit. Did you not write this yourself?
...but at least I can create a file which leaves the comment there.
It's easy then, don't worry about a program that constantly runs and watches for file changes. Take the part of your program you already have, that gets called when this file you mention is made and have it play a sound after changing the file.
I have thought about that, but if I get 100 messages that would just mean 100 messages and doesn't seem very practical
I have seen other programs show a notification on the screen, even though they should be running all the time
I will accept $1 paypal if you want to buy me a cup of coffee, Enjoy!
PS, I didn't test it to make sure that it runs every 60 seconds, but it should update every 59-62 seconds. Hope that is good enough.
Output looks like this on screen, feel free to change it.
1 2 3 4 5 6 7 8 9 10 11 12
Monitoring file "in.txt"for changes in file size.
Looks at file every 60 seconds and beeps if size changes.
When program starts, you should hear a beep to verify sound works.
Runs for 527040 minutes unless user stops. Use (ctrl)-C to stop.
File Size - 9 Bytes
Uptime: (1) Minutes
Uptime: (2) Minutes
Uptime: (3) Minutes
File Updated - LastSize:9 CurrentSize:13 Bytes