I'm trying to write a simple application that skips currently playing track similarly to how media buttons on a keyboard would work.
I have found LParam values for mute (0x80000) but I don't know how to find the values for commands such as next / previous track or how 8 (from article below) maps to 0x80000 so I can work out how map 11 (next track from article below) to a code that works?.
The muting works by using 0x80000 but not when using 8.
Sorry if this is a silly question, I've never done any interop stuff before.
Thanks
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646275%28v=vs.85%29.aspx
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public partial class Form1 : Form
{
private const int WM_APPCOMMAND = 0x319;
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int APPCOMMAND_VOLUME_MUTE_INT = 8;
//private const int APPCOMMAND_MEDIA_NEXT_TRACK = ?;
private const int APPCOMMAND_MEDIA_NEXT_TRACK = 11;
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, int lParam);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// doesn't work
//SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle,
// APPCOMMAND_VOLUME_MUTE_INT);
SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle,
APPCOMMAND_VOLUME_MUTE);
}
}