Press a button on an existing notification (Thumbs up on Google Play Music)

Learn how to take an existing notification and press a button on it

  1. joaomgcd
    Sometimes you want to click on a button in a notification that you receive, but sometimes you may want to click on a notification that already exists.

    For example, you may be listening to a song on Google Play Music and want to thumbs up it.

    STEP 1 - PLAY SOME MUSIC


    • Open Google Play Music
    • Play a song
    • Go back to your home screen so that a notification for Google Play Music is created


    STEP 2 - CREATE THUMBS UP TASK


    • Create a new Task in Tasker
    • Call it Thumbs up


    STEP 3 - QUERY GOOGLE PLAY MUSIC NOTIFICATION


    • Add a new AutoNotification Query action
    • Choose to only query notifications from Google Play Music
    (i) Depending on the notification you're intercepting you may want to specify other criteria to make sure you get the right notification. In this case we're sure there's only 1 Google Play Music notification so it's simple to get it
    • Accept settings and go back to Tasker


    STEP 4 - SHOW NOTIFICATION ACTION



    (i) The Google Play Music notification has 5 action buttons. The one we're interested in is the first one, so we're going to use the %anbutton1action variable. If you wanted to press other buttons you would use %anbutton2action, %anbutton3action, etc.

    • Add a Flash action
    • Set the text to %anbutton1action(1)
    (i) Because an AutoNotification Query action can return multiple notifications, all the variables it produces are arrays (multiple values). In this case, we're sure there's only 1 notification, so we always get the first value, which we do by using (1) at the end of the variable name
    • Accept, go back to Tasker and run the task
    (i) You should see a toast with an ID show up. This ID represents the button action's unique ID.


    STEP 5 - PERFORM BUTTON ACTION


    • Add an AutoNotification Actions Tasker action
    • Use the %anbutton1action(1) in the Intercept Action ID field
    (i) This will actually perform the action contained in the first button of the Google Play Music notification


    STEP 6 - TEST


    If you now run the Task you'll see that it's toggling the Thumbs Up on Google Play Music for this song! :cool: