using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WMPLib;//需要额外添加的引用,win媒体播放器,后缀.dll namespace xxx { class Program { static void Main(string[] args) { while(1==1) { //Console.ReadKey(); //Console.Beep(800, 500); ConsoleKeyInfo ck = Console.ReadKey(true);//读取输入,传入true是为了不显示在控制台上 char c = ck.KeyChar;//用.KeyChar这个方法,将ConsoleKeyInfo类型的值转为char类型 Console.WriteLine(c); WindowsMediaPlayer wm = new WindowsMediaPlayer(); wm.URL = @"D:\vs_code_\trash\xxx_trash\"+c+".mp3";//调用方法,地址是存放音阶的地址(do lai mi fa suo 那些) } } } }
环境:vs2019 windows11
标签:ck,Console,弹奏,小星星,System,using,ConsoleKeyInfo From: https://www.cnblogs.com/qingfeng66/p/17355203.html