سؤال

I have keyboards, as well as the keyboard built into my laptop, which have multimedia keys. One of the multimedia keys is of course pause/play and it's a function of the keyboard driver that can be assigned to other keys. When it's pushed, it will pause/play iTunes, Windows Media Player, etc. depending on what my "last active" media application is.

My question is, in C# how can I duplicate this functionality to be able to pause/play the system sound. I've looked through the API and the only thing that looked close were the winmm.dll waveOutPause and midiOutPause functions

هل كانت مفيدة؟

المحلول

There's a class called SendKeys in .NET that allows you to push keypresses to another application, but this doesn't (AFAIK) allow special keys to be sent.

So instead, I'd guess that you want the API function SendInput.

There's a list of key-codes that includes the media keys here, so you can emulate keys like play/pause or volume controls.

EDIT: a possible alternative to using the API would be to capture whatever your multimedia keyboard sends when you press that key (in a WinForms or WPF app) and then see if you can replicate that keypress using the regular SendKeys implementation.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top