1

On my Microsoft keyboard I have a media player play/pause button.

This button pauses both Spotify, Mediaplay etc. so it's like it broadcasts a play/pause command.

Pressing this button gives me KeyCode = MediaPlayPause in .net.

How can I send this command from .net?

I need to pause/play Spotify from my .net app.

I've tried this...

Keyboard.SendKey(Keys.MediaPlayPause)

...

Public Class Keyboard
    Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Int32, ByVal dwExtraInfo As Int32)

    Public Shared Sub SendKey(ByVal key As Keys)
        keybd_event(CByte(key), 0, 0, 0)
    End Sub
End Class

No luck.

MojoDK
  • 4,410
  • 10
  • 42
  • 80

1 Answers1

0

This has been already answered here
VB Simulate a key press

Anyway the full guide is here http://msdn.microsoft.com/en-us/library/172wfck9.aspx

Community
  • 1
  • 1
AlexF
  • 487
  • 1
  • 5
  • 16