Created
November 30, 2015 16:10
-
-
Save theuntitled/3f6e4b836a47e6b27c18 to your computer and use it in GitHub Desktop.
Send Media Hotkeys with C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.InteropServices; | |
using System.Windows.Forms; | |
namespace MediaHotkeys | |
{ | |
internal class Program | |
{ | |
[DllImport("user32.dll", SetLastError = true)] | |
private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); | |
private static void Main() | |
{ | |
var KEYEVENTF_KEYUP = 0x0002; | |
//var mediaPlayPause = (byte) Keys.MediaPlayPause; | |
//var mediaNextTrack = (byte) Keys.MediaNextTrack; | |
var mediaPreviousTrack = (byte) Keys.MediaPreviousTrack; | |
keybd_event(mediaPreviousTrack, mediaPreviousTrack, 0, 0); | |
keybd_event(mediaPreviousTrack, mediaPreviousTrack, KEYEVENTF_KEYUP, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment