Controlling VLC\MediaMonkey Using C#?

自作多情 提交于 2019-12-23 02:45:43

问题


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);

来源:https://stackoverflow.com/questions/10904447/controlling-vlc-mediamonkey-using-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!