I've been searching for a way to get this functionality with no luck so far. Basically, all I'm trying to do is have a script in AutoHotKey or another program that will pause whatever media I happen to be playing (VLC player, YouTube, Twitch, whatever) if I switch to a different virtual desktop using the standard keyboard shortcut (Ctrl + Win + Arrow). I would just want the script to pause media, I wouldn't want a toggle that would resume play if I returned to that specific desktop.
I'm a new user of AutoHotKey scripts and Windows poweruser stuff in general, so if anybody has some resources that they could point me to where I could learn how to script something like this it'd be appreciated!
Edit: After using the AHK Beginner's Guide that I was given by the very helpful people here along with some other links, I was able to figure out how to do this, with a single line of code in AHK.
All it does is toggle the play media button when I switch desktops to the left, meaning I can have my video running on Desktop 2, then switch to Desktop 1 and have it automatically pause. The "~" symbol just lets the original hotkey be sent to the operating system, so I get to have two functions for one hotkey (in this case, switching desktops and play/pausing media).
Here's the other link I found helpful: