DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   "Global hotkey" Need help :) (http://www.daniweb.com/forums/thread143160.html)

Fragmad Aug 30th, 2008 9:48 pm
"Global hotkey" Need help :)
 
Hello all. I'm pretty new to C++ but not a total beginner. I have done a little program which basicly is a Timer. It's a clock that starts at zero and counts to 4min 45sec, then it playes a sound and restarts.

I want to add a feature which restarts the clock if the user presses the Enter key.

Here's the code (it's not very well organized but doesn't matter in such a small code):
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    int kuk=1;
    int kuk2=1;
    int min;
    int sec;
    bool reset;
   
    while (kuk2 <= 2){
              sec=0;
              min=0;
              reset=false;
             
              while (kuk <= 2){
              PlaySound("alarm.wav",NULL,SND_ASYNC|SND_FILENAME);
              Sleep(1000);
              kuk++;
              }
   
    while (reset == false){
    system("CLS");
    cout << min << ":" << sec;
    sec++;
    Sleep(1000);
   
                if (sec >= 60){
                        min++;
                        sec=00;
                }
                if (min == 4 && sec == 45){
                        reset=true;
                }
               
    }
   
}

return 0;
}


All times are GMT -4. The time now is 1:01 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC