1

I'm trying to simulate the media keys with limited success so far.

I'm reusing the code from here: Send keys through SendInput in user32.dll

and have successfully simulated "VOLUME_DOWN" and "VOLUME_UP" but the MEDIA_NEXT_TRACK and MEDIA_PREV_TRACK aren't working.

my additional code

KeyCode[] actions = new KeyCode[4] { KeyCode.MEDIA_NEXT_TRACK, KeyCode.VOLUME_DOWN, KeyCode.MEDIA_PREV_TRACK, KeyCode.VOLUME_UP};
actionIndex = 0; // actual logic here irrelevant....
SendKeyPress(actions[actionIndex]);

I've made sure that the app I'm using (Metro Music) reacts to the key MediaNextTrack using autohotkey.

What am I missing?

Nir.

Community
  • 1
  • 1
NiRR
  • 4,782
  • 5
  • 32
  • 60
  • Erm, wait, you used code from a question that the author could not get to work correctly himself? Do this the right way, shown in: – Hans Passant Mar 16 '14 at 13:59
  • possible duplicate of [keybd\_event along with PostMessage win32 not working when Visual Studio has focus](http://stackoverflow.com/questions/19157609/keybd-event-along-with-postmessage-win32-not-working-when-visual-studio-has-focu) – Hans Passant Mar 16 '14 at 13:59
  • @HansPassant Thanks! sovled it with WM_APPCOMMAND like said post. it seems that this question has been asked before manay times. http://stackoverflow.com/questions/16743181/simulate-keyboard-event-if-sender-is-not-in-focus-and-without-knowing-target-win – NiRR Mar 16 '14 at 14:52

0 Answers0