Playing Music On Spotify RRS feed

  • Question

  • Basically, I'm trying to use my own "Jarvis" to play spotify when I tell it to play spotify. I've tried to use the sendkeys class to press FN+F9 which is my media key. However, the msdn page on the sendkeys class does not specify a Function key keycode. Is there any other way that I can use to play music on spotify? 
    Tuesday, September 4, 2018 12:58 AM


  • Function key is not a standard key. It is generally used on keyboards to switch the keyboard to an alternative mode such that a key can be in one of several modes. There are a whole series of OEM keys available. Here's the master list of virtual keys supported by Windows. However SendKeys only supports a limited set of keys, not all virtual keys.

    I see a couple of options. The first option is to use the Spotify API and request that it play your music. Then you don't need to worry about activating anything.

    Option 2 is to set up a global hotkey for playing music instead of relying on an OEM key. Whether that would work with the Spotify app or not I don't know.

    Option 3 is to use P/Invoke to switch to the target window. Then use the Win32 SendInput function that does accept virtual keys. Depends upon the app but here is an article on how you might do it.

    Michael Taylor

    Tuesday, September 4, 2018 2:35 AM