STEP 1 - CREATE NEW CHROME PROFILE
- Create a new profile with the App->Chrome condition
STEP 2 - ENABLE KEY SUPPRESS MODE
Enabling Key suppress mode allows you to block the normal function of hardware keys. In this example you're making the volume keys not perform their original function of changing volume, but will share the current page on double click instead
- In the Task, add a new "AutoInput Modes" action
- In the action, enable the "Key Surpress" option
- Go back to Tasker
STEP 3 - DISABLE SUPPRESS ON CHROME EXIT
This will make the volume keys behave normally whenever you're not using Chrome.
- Long click the Entry Task of your new profile and select "Add Exit Task"
- In the task once again add the "AutoInput Modes" action
- Disable Key suppress with this action
STEP 4 - VOLUME UP CONDITION
By selecting "Key down" you'll make this profile trigger only when the volume key is pressed down and not when it's released. If you did not select it, the profile would trigger twice for each button press (once when pressing down on the key and another time when releasing the key)
- Create a new profile with the event->plugin->"AutoInput Key" condition
- In the "Key" field, select "Volume Up"
- In the "Key Action" field select "Key Down".
STEP 5 - INITIALIZE %LASTSECONDS
In the task we're going to react to a double click of the Volume Up key. We'll need to make sure that the key is pressed twice in rapid succession, so we'll need to check when it was last pressed and compare that to the current time. If less then 3 seconds have passed between presses, we will consider it a double click.
This variable will control how much time has passed between each press of the volume up key
- Add a new "Variable Set" action.
- In the "Name" field write %LASTSECONDS
We need to set the variable to 0 if it doesn't have a value. You'll add the "If" condition in the next step.
- In the "To" field, write 0
STEP 6 - ONLY IF %LASTSECONDS ISN'T SET
This will make %LASTSECONDS be set to 0 only if it didn't have a value before. This will only happen the first time you run this Task, because of the end of the task we'll be setting this value.
- Press the plus sign in the "If" line
- In the Left field of the If, write %LASTSECONDS and in the middle button select "Isn't Set"
STEP 7 - CHECK THE DIFFERENCE
We now want to calculate the difference between the time the button was last pressed and the current time
%TIMES is the cucrrent system time in seconds
- Add a "Variable Set" action
- Set the Name to %difference
- Set the "To" field to %TIMES - %LASTSECONDS
%LASTSECONDS is the time that the volume key was last pressed in seconds
STEP 8 - DO MATHS
This will make Tasker calculate the difference between one value and the other
- Check the "Do Maths" option
- Go back to the Task
STEP 9 - CHECK IF THE CALCULATION IS CORRECT
This will allow you to easily check if the calculation above is correct
- Insert a "Flash" action
- In the text field write "Difference is %difference seconds"
STEP 10 - SET %LASTSECONDS TO NOW
This will make the %LASTSECONDS variable be set with the current time in seconds.
- Add a "Variable Set" action
- In the "Name" field write %LASTSECONDS
- In the "To" field write %TIMES
The idea is that with every press of the volume up key, you check the difference between "now" and the last button press, then set the last button press to "now" so you can check it again when you press the key again
STEP 11 - TEST TIMINGS
You can see that the first time you run the app the difference will be huge, because there was no "last time". The second time you run it, the difference will be just a few seconds though.
- Test the task a few times by pressing the play key with different intervals
STEP 12 - ADD IF
This will make Tasker enter this part of the task whenever the value of %difference is lower than 3
- Add an "If" action above the last "Variable Set" action
- Make the condition %diffence < 3
STEP 13 - END IF
- Add an "End If" action just below the "If" action
STEP 14 - ADD UI QUERY ACTION
- Add an "AutoInput UI Query" between the "If" and "End If" actions
- Select the "Variable Setup" option
STEP 15 - FIND URL VARIABLE
- Open Chrome and navigate to any web page
- Make sure that the URL bar is visible, pull down the notification panel, and press the "Accept" button in the AutoInput notification
- Go back to Tasker and select your URL
- Give this variable the name "url" (no quotes)
- Accept these settings and go back to the Task
STEP 16 - FLASH FOR CONTROL
- Add a "Flash" action for control.
- In the text field wite "sharing url %url"
STEP 17 - OPEN URL ON PC
To complete this step you need to have the AutoRemote Chrome Extension installed and set up.
- Add an "AutoRemote Message" action
- In the "Recipient" field select your Chrome "device"
- In the "Message" field write %url
- Accept settings and go back to the Task
STEP 18 - ADD CHROME CONDITION TO AUTOINPUT PROFILE
This will make the volume key only do the sharing on double press if the Chrome app is open and not anywhere else.
- Go back to the profiles Tasker screen and add another condition to the AutoInput profile
- Select the "App->Chrome" condition
- Back out of Tasker so everything's saved.
STEP 19 - TEST
You'll see that a flash will appear showing the difference between the last 2 presses
- Open Chrome and press the Volume Up key once.
You'll first see 2 flashes, each indicating its own difference and then a 3rd flash showing the url. The url should now open on your PC's Chrome
- Make sure that the url address bar is showing and double press the volume key.
For more information, check out the AutoInput category page.
Double Click Volume Up in Chrome To Share Page
Learn how to react to the volume keys so that you can share your currently opened web page in Chrome