#include <iostream>
#include <Windows.h>
using namespace std;
int main()
{
//Variables
static bool x = false;
while (true){
//Button Pressed (Home Key)
if (GetAsyncKeyState(0x24) & 1){
x = !x;
cout << '\a' << endl;
cout << "ON" << endl;
}
}
cin.get();
return 0;
}
//Button Pressed (Home Key)
if (GetAsyncKeyState(0x24) & 1){
x = !x; // change the state of x
if ( x )
cout << "on" << endl;
else
cout << "off" << endl;
}