Skip to content

Instantly share code, notes, and snippets.

@mariotacke
Last active June 21, 2024 06:57
Show Gist options
  • Save mariotacke/5d3e530b554fae7b6d0d9fb2b3292a37 to your computer and use it in GitHub Desktop.
Save mariotacke/5d3e530b554fae7b6d0d9fb2b3292a37 to your computer and use it in GitHub Desktop.
Spotify AutoHotkey Script

Spotify AutoHotkey Script

This script makes use of the Numpad to control media players and volume on your system.

Usage

  • Install AutoHotkey
  • Right-click .ahk script
  • Compile Script
  • Start executable

Hotkeys

  • Ctrl + Numpad 4: Previous Track
  • Ctrl + Numpad 5: Play/Pause Track
  • Ctrl + Numpad 6: Next Track
  • Ctrl + Numpad 8: Volume Up
  • Ctrl + Numpad 2: Volume Down

Visual

     8
     🔊
 4   5   6 
⏮️  ⏯️  ⏭️
     2
     🔉
#SingleInstance force
#NoEnv
SendMode Input
;Ctrl & Numpad 4: Previous Track
^Numpad4::Media_Prev
;Ctrl & Numpad 6: Next Track
^Numpad6::Media_Next
;Ctrl & Numpad 8: Volume Up
^Numpad8::SoundSet +3
;Ctrl & Numpad 2: Volume Down
^Numpad2::SoundSet -3
;Ctrl & Numpad 5: Play/Pause Track
^Numpad5::Media_Play_Pause
@Bdot42
Copy link

Bdot42 commented Apr 4, 2024

For AutoHotKey 2, I'm now using this script (which works no matter if numlock is on or off, and also maps that caps lock key to a normal shift):

#Requires AutoHotkey v2.0

;Ctrl & Numpad 4: Previous Track
^Numpad4::{
Send "{Media_Prev}"
}

;Ctrl & Numpad 6: Next Track
^Numpad6::{
Send "{Media_Next}"
}

;Ctrl & Numpad 8: Volume Up
^Numpad8::{
SoundSetVolume "+3"
}

;Ctrl & Numpad 2: Volume Down
^Numpad2::{
SoundSetVolume -3
}

;Ctrl & Numpad 5: Play/Pause Track
^Numpad5::{
Send "{Media_Play_Pause}"
}

; and again without numlock
;Ctrl & Numpad 4: Previous Track
^NumpadLeft::{
Send "{Media_Prev}"
}

;Ctrl & Numpad 6: Next Track
^NumpadRight::{
Send "{Media_Next}"
}

;Ctrl & Numpad 8: Volume Up
^NumpadUp::{
SoundSetVolume "+3"
}

;Ctrl & Numpad 2: Volume Down
^NumpadDown::{
SoundSetVolume -3
}

;Ctrl & Numpad 5: Play/Pause Track
^NumpadClear::{
Send "{Media_Play_Pause}"
}

;convert cps lock to a normal shift
CapsLock::{
Send "{LShift Down}"
}
CapsLock Up::{
Send "{LShift Up}"
}

@mreduar
Copy link

mreduar commented Apr 4, 2024

I have discovered a more reliable and versatile feature. It is a tool that encompasses various functions and offers the ability to customize multimedia keys with any other key. Surprisingly, I had been using this tool for years without realizing it had this particular function. It was a perfect fit when I finally discovered its capabilities. The tool I am referring to is Microsoft PowerToys, specifically the Keyboard Manager utility.

@ian4blancasa
Copy link

Thx!!! I miss my keyboard that has midia controls.
This made my life easier! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment