I have a WPF application and I want to activate a method when pressing a specific key without the need for the form to be in the foreground, what is the possibility of that solution? Greetings!
private void playSimpleSound(string url)
{
try {
SoundPlayer simpleSound = new SoundPlayer(url);
simpleSound.Play(); }
catch { MessageBox.Show("Error #2"); }
}
private void musicKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.D1)
{
playSimpleSound(ruta1);
}
}