Help with zwift AHK script

I have checked the zwifthacks site and browsed, even tried some coding myself, but i can’t get this done so i’m asking for help here.

I want to use a wireless mouse to controll certain functions in zwift via keybindings, like pgup pgdn for ftp adjust in workouts, but i also want two other buttons on my mouse to function as media next and media previous.
I’ve tried using logitech software, but as soon as zwift is in focus this stops working.
The reason i’m doing this is that i’ve sacrificed an old gaming mouse and wired my discarded gen1 di2 shift buttons to the mouse (purely for indoor use), it’s janky but being able to press a button for certain functions lets me focus on pedaling rather than fiddeling with other prepherials.

I know AHK can do it, but i am not able to make it work.

Is there some genious here who could take a crack at it?
I only need to buttons to be able to send from the active zwift window to spotify, (minimized)
Without it actually bringing spotify to focus.

@Jesper_ZwiftHacks is the resident expert.

1 Like

I actually figured it out after about 4 hours in boiling my brains…
I can now control spotify and all zwift keyboard shortcuts from inside zwift with my old di2 buttons!
If anyone want the same functionality, then simply download Jespers media-button scrips and add
what function you want.

F21:: ; F21 is what i bound my button to in the logitech gaming software
DetectHiddenWindows, On
WinGet, winInfo, List, ahk_exe Spotify.exe
Loop, %winInfo%
{
thisID := winInfo%A_Index%
ControlFocus , , ahk_id %thisID%
ControlSend, , ^{right}, ahk_id %thisID%
}
return

This will cause the defined key to look for spotify and send it the [control]+[right] command for next song

List of more spotify controls are available on the internet.

Thank you for making these things so easy for the rest of us @Jesper_ZwiftHacks
And feel free to take my “contribution” and use it however you please if you want. :slight_smile:

3 Likes

Great that you figured it out!

2 Likes