Send {Media_Play_Pause} is inconsistent

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
aandf
Posts: 1
Joined: 26 Apr 2017, 07:46

Send {Media_Play_Pause} is inconsistent

26 Apr 2017, 08:01

Hi - I'm pretty new to AHK, so there's a solid chance I'm doing something dumb here.

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: downstairs, Google [Bot] and 189 guests