I'm writing an application that allows you to control VLC and\or Media Monkey without having to interact with the application itself. The problem I have is that the method I am using right now uses WM_APPCOMMAND which only works with Windows Media Player.
I have searched a lot, and cannot seem to find a solution that will let me send the global media key (as in VK_MEDIA_PLAY_PAUSE) globally within a console application. The only was people have said to make this happen is to foreground the application first.
Here is what I have so far:
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
SendMessageW(handle, WM_APPCOMMAND, handle, (IntPtr)APPCOMMAND_MEDIA_PLAY_PAUSE);
I should note that this is something I am just hacking together for personal use, so it doesn't need to be a simple fix, just one that works.
Thanks in advance
Edit: In case anyone is looking for the solution, here is what I had to do:
private const int WM_KEYDOWN = 0x0100;
[DllImport("user32.dll")]public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true)] static extern IntPtr FindWindow(string lpszClass, string lpszWindow);
IntPtr vlc = FindWindow(null, "VLC Media Player");
PostMessage(vlc, WM_KEYDOWN, ((IntPtr)Keys.P), IntPtr.Zero);