[WPF] Accéder au volume général

Jayme65 Messages postés 60 Date d'inscription lundi 23 avril 2007 Statut Membre Dernière intervention 26 mars 2019 - 10 déc. 2015 à 19:41
vb95 Messages postés 3472 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 13 avril 2024 - 11 déc. 2015 à 18:00
Bonjour,

Pourriez-vous me dire comment faire pour accéder au volume général (volume système) sous WPF?

Merci!!

5 réponses

Whismeril Messages postés 19026 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 20 avril 2024 656
10 déc. 2015 à 20:48
Ha autant pour moi.

Sinon, en C# il y a de nombreux exemples, il suffit ensuite de les passer dans un traducteur en ligne.

Ici par exemple
http://stackoverflow.com/questions/13139181/how-to-programmatically-set-the-system-volume
1
Jayme65 Messages postés 60 Date d'inscription lundi 23 avril 2007 Statut Membre Dernière intervention 26 mars 2019 2
11 déc. 2015 à 14:30
J'ai donc ceci qui semble tenir la route !? (en C#):

using System;
using System.Windows;
using System.Runtime.InteropServices;

namespace WpfApplication2
{
public partial class MainWindow : Window
{
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int APPCOMMAND_VOLUME_UP = 0xA0000;
private const int APPCOMMAND_VOLUME_DOWN = 0x90000;
private const int WM_APPCOMMAND = 0x319;

[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

IntPtr handy = GetForegroundWindow();

public MainWindow()
{
InitializeComponent();
}

private void button1_Click_1(object sender, RoutedEventArgs e)
{
SendMessageW(handy, WM_APPCOMMAND, handy, (IntPtr)APPCOMMAND_VOLUME_MUTE);
}

private void button2_Click(object sender, RoutedEventArgs e)
{
SendMessageW(handy, WM_APPCOMMAND, handy, (IntPtr)APPCOMMAND_VOLUME_UP);
}

private void button3_Click(object sender, RoutedEventArgs e)
{
SendMessageW(handy, WM_APPCOMMAND, handy, (IntPtr)APPCOMMAND_VOLUME_DOWN);
}
}
}


J'aimerais maintenant pouvoir récupérer la valeur du volume système actuel quand l'application est lancée.
J'ai vu [URL="http://stackoverflow.com/questions/27728087/c-sharp-what-are-these-volume-changing-codes-messageshttp://"]ici/URL que "It has a macro called GET_APPCOMMAND_LPARAM() which retrieves the actual value from the param."

Comment pourrais-je incorporer à ce code (toujours en WPF) cette macro et ainsi pouvoir récupérer le volume actuel?
1
Whismeril Messages postés 19026 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 20 avril 2024 656
10 déc. 2015 à 20:29
Bonsoir,

voir ici
http://lakeofsoft.com/vcx/volume-control.html

C'est en winform, mais la partie graphique importe peu
0
Jayme65 Messages postés 60 Date d'inscription lundi 23 avril 2007 Statut Membre Dernière intervention 26 mars 2019 2
10 déc. 2015 à 20:42
Ceci est un lien vers un composant payant!?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
vb95 Messages postés 3472 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 13 avril 2024 169
11 déc. 2015 à 12:24
0
vb95 Messages postés 3472 Date d'inscription samedi 11 janvier 2014 Statut Contributeur Dernière intervention 13 avril 2024 169
11 déc. 2015 à 18:00
Salut je suis à côté de la plaque avec le code ci-dessus ! C'est un module qui permet grâce à un Slider de régler le volume sur un PC
Rien à voir avec ta demande
0
Rejoignez-nous