¿Cómo puedo hacer que el ordenador suene en C#?
¿Cómo hago que el altavoz interno del ordenador suene en C# sin altavoces externos?
6 answers
En.Net 2.0, puede usar la consola.Beep().
// Default beep
Console.Beep();
También puede especificar la frecuencia y la longitud del pitido en milisegundos.
// Beep at 5000 Hz for 1 second
Console.Beep(5000, 1000);
Para más información consulte http://msdn.microsoft.com/en-us/library/8hftfeyw%28v=vs.110%29.aspx
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-08 13:15:46
También puede utilizar el relativamente no utilizado:
System.Media.SystemSounds.Beep.Play();
System.Media.SystemSounds.Asterisk.Play();
System.Media.SystemSounds.Exclamation.Play();
System.Media.SystemSounds.Question.Play();
System.Media.SystemSounds.Hand.Play();
La documentación para estos sonidos está disponible en http://msdn.microsoft.com/en-us/library/system.media.systemsounds (v=vs.110). aspx
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-07 13:14:17
Consola.Beep
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-11-26 15:40:21
Prueba esto
Console.WriteLine("\a")
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-15 18:24:45
Se confirma que win7 y las versiones más recientes (al menos 64 bits o ambas) no usan el altavoz del sistema y en su lugar enrutan la llamada al dispositivo de sonido predeterminado.
Entonces,usar system.beep()
en win7/8/10 no sonará usando el altavoz interno del sistema. Pero obtendrá un pitido de altavoces externos si está disponible.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-21 04:42:35
Me encontré con esta pregunta mientras buscaba la solución para mí mismo. Podrías considerar llamar a la función system beep ejecutando algunas cosas de kernel32.
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
public static extern bool Beep(int freq, int duration);
public static void TestBeeps()
{
Beep(1000, 1600); //low frequency, longer sound
Beep(2000, 400); //high frequency, short sound
}
Esto es lo mismo que si ejecutaras powershell:
[console]::beep(1000, 1600)
[console]::beep(2000, 400)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-31 11:11:24