Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send multimedia commands

Tags:

c#

Is there some way that I can send multimedia control commands like next song, pause, play, vol up, etc. to the operating system? Commands that are sent when pressing Fn + some mapped ..key. I am making a remote control for PC and sending those commands is essential.

like image 966
Milan Avatar asked Feb 21 '13 22:02

Milan


People also ask

What can you send via MMS?

While SMS was built to send short messages, MMS focuses on sending multimedia messages. Some of the rich content types which can be sent include phone contacts, audio and video files and images.


1 Answers

You can use keybd_event to simulate keys presses, you have to simulate key down and then key up in order to recognize correctly

    [DllImport("user32.dll", SetLastError = true)]
    public static extern void keybd_event(byte virtualKey, byte scanCode, uint flags, IntPtr extraInfo);
    public const int VK_MEDIA_NEXT_TRACK = 0xB0;
    public const int VK_MEDIA_PLAY_PAUSE = 0xB3;
    public const int VK_MEDIA_PREV_TRACK = 0xB1;
    public const int KEYEVENTF_EXTENDEDKEY = 0x0001; //Key down flag
    public const int KEYEVENTF_KEYUP = 0x0002; //Key up flag

    private void ButtonClick(object sender, EventArgs e)
        keybd_event(VK_MEDIA_PREV_TRACK, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
        keybd_event(VK_MEDIA_PREV_TRACK, 0, KEYEVENTF_KEYUP, IntPtr.Zero);
    }`
like image 114
dxramax Avatar answered Oct 05 '22 20:10

dxramax