2009年4月9日 星期四

Windows效果音 piano

看了nm6626195之后一时冲动就搞了这么一个东西出来
(当然仅凭这个还是无法完成nm6626195里那些事情的)

功能 : 按键→Windows提示音
操作方法:按压键盘
按键列表
Esc → 退出
1~3 → 设置模式

发音键:
qwer uiop
asdf jkl;
zxcv nm,.

下载地址:http://www.jsharer.com/file/1139519.htm

09-04-25 公开源代码

//Window events for PlaySound

/*

AppGPFault
BlockedPopup
BuildComplete
BuildError
BuildWarning
CCSelect
Close
CriticalBatteryAlarm
DeviceConnect
DeviceDisconnect
DeviceFail
EmptyRecycleBin
LowBatteryAlarm
MailBeep
Maximize
MenuCommand
MenuPopup
Minimize
MoveMenuItem
Navigating
Open
PrintComplete
RestoreDown
RestoreUp
SecurityBand
ShowBand
SystemAsterisk
SystemExclamation
SystemExit
SystemHand
SystemNotification
SystemQuestion
SystemStart
WindowsLogoff
WindowsLogon
*/
#include <stdio.h>
#include <windows.h>
#include <conio.h>
#pragma comment(lib,"winmm.lib")
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
void SetConsole()
{
   
SetConsoleTitle("Windows Media Piano by wye-MIA kid C!");
   
SetConsoleTextAttribute(hOut,0xf8);
   CONSOLE_SCREEN_BUFFER_INFO
csbi ;
   
GetConsoleScreenBufferInfo(hOut,&csbi);
   
DWORD written ;
   
DWORD N=csbi.dwSize.X*csbi.dwSize.Y;
   COORD
curhome={0,0};
  
    
FillConsoleOutputCharacter(hOut,' ',N,curhome,&written);
   
FillConsoleOutputAttribute(hOut, csbi.wAttributes,N,curhome, &written);  
   
    
csbi.srWindow.Bottom-=csbi.srWindow.Top ;
   
csbi.srWindow.Top=0 ;
   
SetConsoleWindowInfo(hOut,TRUE,&csbi.srWindow);
   
SetConsoleCursorPosition(hOut,curhome);
}
void main()
{
   char
key = 0;
   
UINT fuSound = SND_ASYNC;
   
SetConsole();
  
    while (1)
   {
       
key = 0;
       if (
kbhit())
       {
           
key = getch();
           
SetConsoleTextAttribute(hOut,0xF0|key);
           switch (
key)
           {
           case
'a':
               
sndPlaySound("DeviceDisconnect",fuSound);
               break;
           case
's':
               
sndPlaySound("DeviceConnect",fuSound);
               break;
           case
'd':
               
sndPlaySound("DeviceFail",fuSound);
               break;
           case
'f':
               
sndPlaySound("LowBatteryAlarm",fuSound);
               break;
           case
'j':
               
sndPlaySound("SystemAsterisk",fuSound);
               break;
           case
'k':
               
sndPlaySound("SystemExclamation",fuSound);
               break;
           case
'l':
               
sndPlaySound("MailBeep",fuSound);
               break;
           case
';':
               
sndPlaySound("notify",fuSound);
               break;
           case
'q':
               
sndPlaySound("SystemExit",fuSound);
               break;
           case
'w':
               
sndPlaySound("SystemStart",fuSound);
               break;
           case
'e':
               
sndPlaySound("WindowsLogon",fuSound);
               break;
           case
'r':
               
sndPlaySound("WindowsLogoff",fuSound);
               break;
           case
'u':
               
sndPlaySound("chord",fuSound);
               break;
           case
'i':
               
sndPlaySound("ding",fuSound);
               break;
           case
'o':
               
sndPlaySound("http://wye-ANGer.blogspot.com",fuSound);
               break;
           case
'p':
               
sndPlaySound("SystemHand",fuSound);
               break;
           case
'z':
               
sndPlaySound("SystemNotification",fuSound);
               break;
           case
'x':
               
sndPlaySound("start",fuSound);
               break;
           case
'c':
               
sndPlaySound("recycle",fuSound);
               break;
           case
'v':
               
sndPlaySound("chimes",fuSound);
               break;
           case
'm':
               
sndPlaySound("CriticalBatteryAlarm",fuSound);
               break;
           case
',':
               
sndPlaySound("tada",fuSound);
               break;
           case
'.':
               
sndPlaySound("ringout",fuSound);
               break;
           case
'/':
               
sndPlaySound("ringin",fuSound);
               break;
           case
'1':
               
fuSound = SND_ASYNC;
               break;
           case
'2':
               
fuSound = SND_SYNC;
               break;
           case
'3':
               
fuSound = SND_ASYNC|SND_LOOP;
               break;
           case 27:
               return;
           default :
               
printf("\n--------------Help--------------\n"
                      "\nDefined keys:\n"
                      "qwer uiop\n"
                      " asdf jkl;\n"
                      "  zxcv m,./\n"
                      "\nPress key 1~3 to set mode\n");
           }
       }
   }
    return;
}

1 則留言: