I created the script below to do a "soft pause" - it ramps down master volume, sends out a Media_Play_Pause, and then ramps master volume back up.
I'm running it in interpreted mode (or whatever the right term is for running it without compiling).
When executing, the Send {Media_Play_Pause} seems rather inconsistent - the volume always seems to ramp up and down, but sometimes the music doesn't pause, and sometimes it doesn't start. I've made sure there are sleeps before and after any commands to see if that made any difference - it doesn't seem to have.
Any suggestions?
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;play/pause
^j::
SoundGet, master_volume
previous_volume := master_volume
while (master_volume > 0)
{
SoundSet -1
Sleep, 65
SoundGet, master_volume
Sleep, 10
}
Send {Media_Play_Pause}
while (master_volume < previous_volume)
{
SoundSet +1
Sleep, 65
SoundGet, master_volume
Sleep, 10
}
Return