|
This document is a one-page compilation of the on-device userguide
intended for printing out for use as a reference.
Tasker Userguide
- Profiles
- Contexts
- Tasks
- Scenes
- Variables
- Miscellaneous
- FAQs
- Web Links
Main Screen
This is the first screen shown when you startup Tasker. It allows you
to organize and configure Tasker's four main 'building blocks':
Profiles, Tasks, Scenes and Variables.
Main Tabs
- Click on a tab to view a list of the relevant things
- Long-click on a tab to get options
Profiles
Each item in the list represents a profile. The profile links contexts (conditions) on
the left to tasks which should be run on the right. The profile name is green if
the profile is active. There are three main parts to each profile.
1. Title Bar
This shows the profile name (or description if it has no name) and the
check-mark icon on the right shows whether the profile is enabled or not.
- Click on the name to expand / collapse the profile. When expanded, the contexts and tasks (described below), are visible.
- Long-click on the profile name to get profile options
- Click on the check-mark icon to toggle whether the profile is enabled or not.
- Click-and-drag the area at the right side of the title bar
drag it around. Note that the enable icon can also be used for dragging.
Important: the check-mark does not mean the profile is active
(will run its tasks), it means that the profile can become active
if its conditions are met.
2. Contexts
On the left hand side of the profile are an icon and text for each context in the
profile. The contexts dictate when the profile should become active. When all contexts
are active then the profile will be active.
- Click on the context to edit it
- Long-click to show management options, such as editing or adding a new context
You can configure what clicks and long-clicks on contexts do in Menu / Prefs / UI.
3. Tasks
On the right hand side of the profile are one or two tasks to
carry out based on its activation status.
- Click on the task to edit it
- Long-click to show management options.
A task indicated with a green, right-pointing arrow is an
entry task, executed when the profile first becomes active.
A task indicated with a red, left-pointing arrow is an
exit task, executed when the profile becomes inactive again.
Exception: a profile containing an event context or a repeating
or non-ranged time context has two green
arrows, to denote that both tasks are executed immediately because
the profile activation and deactivation is instantaneous.
Tasks
The task list shows the named tasks which have been created.
- Click on a task to edit it
- Long-click for options
- Click-and-drag at the right hand side to drag the task (e.g. to the trash bin)
Note that a profile can be assigned an anonymous task (one without
a name) which is not accessible in the task list, only via the
relevent profile in the profile list.
Scenes
The scene list shows the scenes which have been created.
- Click on a scene to edit it
- Long-click for options
- Click-and-drag at the right hand side to drag the scene (e.g. to the trash bin)
Scenes marked with a star icon have been created but may be visible or invisible.
Variables
The Variables tab is not shown if Menu / Prefs / UI / Beginner Mode is enabled.
By default, all global user-variables that Tasker knows about are listed, which includes any that have a value set or are mentioned somewhere in a profile or task.
- Click on a variable to edit it
- Long-click for options
Note that variables whose names are all lower-case are local variables and not shown because they are only valid within the task that refers to them.
At the bottom of the variable list is an upwards-pointing faded arrow.
It can be dragged up to show variable filter controls.
- Indexed (button)
includes variables whose names end in a number e.g. %LOC3, otherwise they are excluded.
- Empty (button)
includes variables which have currently have no value assigned, deselect to show only variables that have a value.
- Referenced (button)
includes variables which are referenced in profiles or tasks. Deselect to show 'orphan' variables.
- Filter (textbox)
excludes variables which don't contain the specified text somewhere in their name (case-sensitive)
Unlike most screens in Tasker, changes made in the variable list cannot be cancelled.
Bottom Controls
Cancel Button
Discard all changes to user data that have been made
since starting the Tasker UI.
Accept Button
Apply the changes that have been made since last starting the Tasker UI.
Pressing the Back hardware button has the same effect. Home has the same
effect unless a dialog is showing.
Plus Button
Create a new Profile, Task, Scene or Variable, depending on the current tab.
On/Off Toggle
Tasker does not do anything when you leave the user inteface, unless
this button is set to On (green light showing). When you set
it to off, Tasker's event monitor is immediately stopped if it was
previously running.
Projects
Tasker allows organisation of profiles, tasks, scenes and variables
into groups called Projects, each with a separate Project Tab.
The projects tabs are accessed by dragging entity tabs down
via the faded arrow just underneath them. Drag the other way
to hide them.
If no arrow is there, you probably need to disable Menu / Prefs / UI / Beginner Mode.
- Click-and-drag a profile, task or scene to a project
tab to move it to that project
- Click on a project tab to switch to viewing only
things in that project
- Long-click on a project tab for options, including
adding a new tab
The first tab has a slightly special status, it cannot be removed
and anything which is not a member of another project is placed there.
Menus
Menu Item: Browse Solutions
Links to websites with projects, profiles etc offering solutions for common
problems. Important: once downloaded you need to import the file into
your active user data. For example, profiles are imported by long-clicking
the profile tab and selecting Import.
Menu Items: Data
Clear
Removes all data that has been created to that point. Does
not remove preferences (use Menu / Preferences and click Defaults for
that) or variables (long-click on the Variables tab for that).
Backup
Saves the existing user data to a backup file on the SD card (if present).
The file is /sdcard/Tasker/userbackup.xml.
Restore
Replaces the existing profile configuation with that from the SD card.
Application Context
An Application Context is activated when the selected application is running
in the foreground and deactivated otherwise.
The button in the bottom right indicates whether the context is inverted
or not. If the button is lit-up, this context will become active when any
application apart from the selected one is launched.
Application Checking
When any profiles have application contexts specified, Tasker checks frequently
to see if one of those applications has been launched. The default is every
1.5 seconds.
If you would like quicker response, or you suspect this is severely increasing
your battery usage, you can change this value in preferences
(select Menu / Preferences / Monitor from the main screen).
Time Context
A Time Context specifies a particular range, or one (or more) points in time.
There are three major components in the selection dialog, one of which must be selected (by enabling
its checkbox on the left):
- From Time: the starting time of the range. If it's not specified,
00:00 is assumed.
- To Time: the end time of the range. If it's not specified, 11:59
is assumed.
- Repeat: if no repeat is selected, the context is assumed to be
a continuous range which starts at From Time and ends at To Time.
If a repeat is specified, the first occurrence is at From Time and then
every X hours or minutes until End Time.
Notes:
- to specify a precise time, set From and To times the same. In that case, the context is treated as an instant event,
it it only active for a fraction of a second, so no setting restoration is done.
- each repeat (if Repeat is set) is also treated like an instant event.
Day Context
A Day Context allows specification of one or more months and/or days of the
week/month.
Month Specification
The months are listed at the top, any of which can be selected. Selecting no
month has the same meaning as selecting every month i.e. has no restriction
on when the profile will become active.
Day of Week/Month Specification
Days of the week (Sunday, Monday etc) and/or month (1st, 9th etc) can be selected
independently with the pulldown centre-right. This will initially be for Week Days if
there are any defined, otherwise Month Days.
Selecting no day has the same meaning as selecting every day.
If you select both days of the week and days of the month, it requires both
conditions to be fulfilled for the profile to become active
e.g. selecting Mon,Tue and 11th means the profile will become active when the
day is a Mon or Tuesday and simultaneously the 11th day of the month.
If you are unsure if you have specified the day(s) you require, click the Done
button and you will see a verbal description at the top of the Profile Edit screen.
You can click on this to try again if it's not correct.
Location Context
A location context specifies a circular geographical area in which
it is active. It is formed by a centre point (latitude, longitude) plus
a radius around that point.
Location Providers
A location provider is a method of supplying geographical coordinates. Tasker must
use one or more location providers to be able to decide when a location context
should become active or inactive.
GPS
The most accurate provider available (around +-10m), but its performance degrades quickly
indoors and it uses a relatively large amount of power.
To set the frequency of GPS fixes, see Menu / Preferences / Monitor.
GPS Check Time determines the check frequency in seconds while the device
is awake, Off Check Time while the device is asleep.
GPS will only be used for a particular context if it is specified in the location
edit screen.
Network
This provider uses a combination of cell-towers
and WiFi information (if wifi is enabled) to determine the device's geographical location. It is
less power-hungry than GPS, but also less accurate (sometimes +- several kilometres)
and requires data network availability.
Network will only be used for a particular context if it is specified in the location
edit screen.
See also:
Location Edit
This screen allows configuration of a Location Context.
Map Display
The map shows:
- The location (base of the flag icon) and names of all defined location contexts
- The radius of the location currently being defined (the inner circle)
Location contexts other than the one currently being defined have a small fixed-radius bluish
base.
Map Controls
Use a long-click on the map to select a location for this context.
Use the pull-down selector under the map to specify the radius
for this context.
Important: if your radius is too small compared to the accuracy of
the fixes you are receiving, your context may never go active. If you can't get
a fix, try increasing the radius. Typically, a good radius would be around twice the
accuracy of the fixes you are receiving.
Tap on the map to bring up zoom controls and buttons to enable the Satellite
Overlay (left) and Street View (right). Note that the Street View sometimes does
not update until the map is dragged slightly.
If you have no internet available in order to retrieve the map tiles, you can still use
the Get Fix button (see below) to specify your current location.
Bottom Buttons
Net Button
The Net toggle button specifies whether to use the
Network location provider
to monitor for this location
GPS Button
The GPS toggle button specifies whether to use
GPS
to monitor for this location
(assuming it is available on the device). If GPS is not used, the network will need
to be available in order to query for location fixes based on cell-towers or WiFi
data.
Get Fix Button
Acquires a location fix using the enabled and available providers (make sure the GPS
Button is clicked first if you want to use GPS).
Once a fix is acquired, the latitude, longitude and radius of this location context
are set according to it. If you reduce the radius after a fix, Tasker may no longer
accurately detect whether you are in or out of the context.
When trying to determine current location, Tasker will keep going with fixes until they stop improving (e.g. as the
GPS locks on to more satellites). If you get impatient you can press the Get Fix button
again to stop the process (its label is changed to Stop while a fix is being
acquired).
State Context
A State Context allows specification of the continuing state
of a software or hardware entity.
The State Edit screen allows configuration of the state and its
parameters.
State Name
The name of the state is given at the top of the screen.
Clicking on it allows changing to another state type.
Next to the name is a button to show help for the
displayed state type and its parameters. Be sure to check the
help text if you have trouble with a particular state.
State Parameters
General Parameters
All states have parameters to specify more details about the state.
Text parameters are treated as pattern matches.
Invert Parameter
All states have an invert parameter, which specifies that the context should
become active when it would usually be inactive, and vice-versa.
Event Context
An Event Context allows specification of an event
which is needed to activate its profile e.g. SMS received,
screen has gone off.
Events are a little different to other contexts because they
are instantaneous whereas other contexts usually have
a duration.
This means that it is nonsensical to specify that e.g. the
screen brightness should be set to X for the duration of the
event, so Tasker assumes that all settings
actions should persist beyond the event.
For more information about specifying events, see
the Event Edit screen.
Event Parameters
When a task is triggered by an event, the parameters of the event that
ocurred are passed to the task so that it can make decisions based
on the event details.
The parameters are passed in the array
%evtprm.
The order of elements of the array have values which match the order
of the parameters of the event.
Example: if an event's second parameter is an Application, %evtprm2
in the launched task will be set to the label of the application
which triggered the event.
Event Edit
This screen allows configuration of an Event Context.
Event Name
The name of the event is given at the top of the screen.
Clicking on it allows changing to another event type.
In the top right is a button to show help for the
displayed event type.
Priority
Only present for relevant events.
Selects the priority at which this event will be detected.
An event can be processed by other Tasker Profiles, other
installed applications and system processes.
If priority is high, then this profile will be more likely
to detect the event before other processes, and vice versa.
Stop Event
Only present for relevant events.
If checked, then once this profile has dealt with the event,
other user or system applications will no longer be able to
see it.
You can achieve different effects by combining Priority
and Stop Event. For instance, if you want to show a Tasker menu
when the camera button is pressed, you would set Priority High
and check the Stop Flag, because you do not want the
camera application to appear afterwards.
Event Parameters
Some events have paramaters to specify more details about the event.
To get help on particular parameters, click the question-mark icon
at top right.
Text parameters are treated as pattern matches.
If you would like to make more complex comparions (e.g. mathematical expressions), leave the event parameter
blank and instead put a condition on the first
action of the task you execute with the profile.
Tasks
A task is simply a set of actions which are performed one after the other.
Named / Anonymous Tasks
A task can be given a name. This allows:
- the same task to be used in more than one profile
- easier identification of what the task does
- in the case of a task widget/shortcut,
it provides a label for the icon on the home screen.
When creating a profile, widget or shortcut,
often the associated task will consist only of one or two actions which will not
be reused. For this case, Tasker allows you to create a task without a name
(an Anonymous task).
Task Visibility
Anonymous tasks are only visible when editing the profile that they are associated
with.
Named tasks are visible on any screen that allows task editing.
Any changes made to the set of tasks in any screen is reflected in all the other
screens.
Task Icon
Each task has an associated icon, by default a question mark. The icon is used
Deleting Tasks
Named tasks can only be deleted via the Delete button on the
Task Edit screen. Unnamed tasks
are deleted automatically when the profile they are part of is deleted,
or a named task is selected for that profile.
Named tasks cannot be deleted while a profile still refers to them.
When a task is deleted that is referred to by a previously created named
widget or task, the widget will stop working.
Android does not allow Tasker to automatically remove the widget from the
Home Screen.
Task Scheduling
When there is a single task waiting to be executed, it's actions are executed one-by-one
until finished.
When there are several tasks in the queue at once, it's important to understand
how they are handled:
- only one action from the same action group can be executed at once to
prevent interference
- the task in the queue with the highest priority goes first and blocks lower priority tasks
- tasks with the same priority take turns executing an action
each, starting with the most recent addition to the queue
Task priority, 0 to 10 inclusive with 0 being lowest, is determined according to whatever causes the task to run.
- tasks run by profiles have the priority specified in Profile Properties, the default is 5
- tasks run by widgets or shortcuts can be set in
Menu / Prefs / Action, the default is 7
- tasks run from scene elements have priority one more than the task which showed the scene
- tasks run from the Test button in the task edit screen have priority 10
A couple of guidelines are:
- if you want a particular task to always interrupt other tasks that may be
executing, give it a high priority
- if you have a task that lasts for a while,
you probably want to give it a low priority so it doesn't block other tasks
from being executed.
Action Groups
Actions are divided into groups for scheduling based on how long the action takes to execute and what it
interferes with:
- Speech:
Say, Say To File
- Javascript:
Javascript
- Fix:
Get Location
- Voice:
Get Voice
- Proxy:
Display Brightness, Query Action, Photo, Photo Series, Photo Series Time
- Proxy Scene Enter Key, Menu, Popup, Popup Task Buttons, Variable Query
- Other Scenes: the name of the scene being shown
- Normal: all other actions
Wait Actions
Wait and Wait Until are special cases. The rules for handling them are complicated
and try to do the 'best thing' dependent on the situation.
Same-Profile Tasks
Tasks launched by the same profile by default always execute in the order in which they are launched. Other tasks from the same profile remain completely inactive until any previous task from the same profile is complete. The main purpose of this rule is to correctly handle rapid changes in a profile's activation state.
This behaviour can be disabled by deselecting Enforce Task Order in the Profile Properties dialog.
Example
This example demonstrates the effect of Enforce Task Order and shows also how sub-tasks launched by
Perform Task are handled.
Profile: Example
Enter Task: Enter1
Perform Task, Enter2
Exit Task: Exit1
Perform Task, Exit2
With Enforce Task Order:
Enter1 and Enter2 are both guaranteed to finish before either of Exit1 or Exit2. Whether Enter1 or
Enter2 finishes first depends on their relative priority. Same for Exit1 and Exit2.
All 4 tasks compete based on priority against tasks from other profiles. Exit tasks have a higher base
priority so will finish before Enter tasks.
Without Enforce Task Order:
If the profile goes active and inactive quickly, Enter1, Enter2, Exit1 and Exit2 will all compete
purely on priority. Since Exit tasks have higher base priority, Exit1 and Exit2 will probably finish first.
Collisions
Sometimes a task needs to be executed of which a copy is already executing.
This can happen quite often e.g. when a task widget button is pressed twice quickly,
or a task contains a Wait action or shows a dialog.
The way in which a collision is resolved is specified by the user. There are
3 options:
- the new task is ignored (the default)
- the existing task is aborted and the new one starts from its first action.
The current action of the previous task is finished if it is already being carried out.
- both tasks run simultaneously
Note that the last option can lead to several copies of a task all running at once.
Behaviour When Device Off
By default, after a few seconds of the screen being off Android will power down the device and thus running
tasks will be paused.
In the Task Properties dialog, it can be specified that a task should keep running.
Dialogs
An action that shows some kind of dialog (such as a lock screen, popup, menu)
blocks execution of any other action, even one of higher priority, until it is completed.
Wait / Wait Until
These are exceptions. A wait action can be interrupted by another task's action and
will resume (if necessary) when the other task's action is finished.
Killing Tasks
If you have a problem with a task that never ends, you can manually end tasks
with the Kill button in the Task Edit screen.
Task Edit
This dialog allows editing and deletion of a task.
Action List
The main part of the screen is a list of the actions contained in the currently
selected task.
- Click on an action to edit it
- Long-click on an action for options
- Click-and-drag at the right hand side of the action to move it around e.g. to the trash bin
On the right of each action is an icon stipulating whether the
action is a setting or not. See here for
more information.
Condition and Block Colours
If an action has had a condition set for it, the condition is shown with
a red or green bar next to it; green indicates that the condition is currently met (the action will execute), red indicates the opposite. Of course, when the task is executed it could be that it changes things so that the condition is then met.
If an action is within an If / End If block it is displayed
indented with a red or green margin. The colours have the same significance
as for individual action conditions described above.
If an action is within a For loop it
is displayed indented with a grey margin. If the For
action has a condition on it which is not met, the margin will be red
(because the actions in the loop will never execute, like an If / End If block).
Task Control Row
Directly underneath the action list is a row of buttons with icons.
- Add Action: add an action on the end of the task.
- Task Properties: show extended properties for the task.
- Task Icon button: shows the icon associated with the task. Clicking on it
allows changing of the icon.
Bottom Row Buttons
Test Button
Run the task. Be aware that if the Task e.g. loads another
activity, you must return to Tasker and press save otherwise all changes made
while in the Task Edit screen will be lost.
Tasks run via the Test button have priority 10.
Kill Button
This button in the bottom right will stop all running tasks. It is not
displayed if there are no running tasks.
Menu Items
Action Labels
Toggle display of action labels (which are specified in the Action Edit screen).
Param Names
Toggle display of the name of each action parameter.
Icons
Toggle display of the setting/action indicator icon for each action.
Action Edit
This screen allows configuration of a single action in a Task.
General
At top left is the name of the action. Tapping on this allows it
to be changed.
Bottom-right is a help button. Please be sure to read the action help
of every action before you use it for the first time, there may be e.g. device specific restrictions you should know about.
Action Parameters
A parameter gives extra detail about how the action is to be carried out.
Text Parameters
- are sometimes optional: in that case the text Optional
will appear as a hint unless the entry box has already been filled in
- sometimes have a dialog to help you fill in a value
which you can access by clicking the magnifying glass icon next to them
- can have variables automatically inserted by clicking the tag
icon next to them.
Numeric Slider Parameters
Clicking the arrows icon next to numeric sliders allows you to specify the
number textually or use a variable for the parameter instead, if the value
will not be known until the action is actually executed.
If (Condition) Parameter
(most actions)
Allows specification of a condition which must match if
this action is to execute.
Please see the section on Flow Control for more information.
Continue Task After Error Parameter
(selected actions only)
By default, if an action fails with an error (e.g. the user specified to delete a file that doesn't exist)
Tasker will stop the task immediately and the remaining actions will never be executed.
This parameter specifies that the task should continue even if this action fails.
In addition, if it's checked, errors will be logged in the system log as diagnostics instead of errors
and error popups will be surpressed.
Label Parameter
(all actions)
A label for the action which is shown on the Task Edit screen. This parameter
could also be used to add comments to actions to help understand
how the task works.
Labels are also used with Goto actions to jump from one part of
the task to another.
Scenes
Introduction
A scene is a graphical user-interface consisting of a collection of elements to which tasks can be attached to be run when the user interacts with them e.g. by tapping them.
Tasker uses scenes for things like popup dialogs, menus and getting input from the
user but scenes can actually be displayed by the user whenever desired, meaning
they can be used for things like creating simple user-designed applications or showing extra controls over the top of (selected) existing applications.
Scenes are completely user-customisable via a drag-and-drop graphical editor.
Displaying Scenes
Actions: Enter Key, HTML Popup, Lock, Menu, Popup, Popup Task Buttons and
Variable Query
These actions use a built-in scene with the same name as their action.
After creating a task with such an action, the associated scene can be found
under the Scenes tab on the main Tasker screen. That scene can be edited so that
e.g. all Popup actions have the same style because they all use the same scene.
The parameters specified in the action are applied to the scene before it
is show. For instance, if the scene has a Title element it will be
set to the title specified in the action and the scene resized appropriately.
It might be desirable to have a different style for e.g. some Popup actions, in which case:
- clone the built-in scene long-clicking on it in the Scenes tab
- edit the clone to change the contents
- in a
Popup action, specify that the cloned scene should be used
by clicking on the Layout parameter in the action edit screen.
Scene Category Actions: Create Scene, Show Scene, Hide Scene, Destroy Scene
These allow a completely free hand over when a scene should be displayed and it's
life-cycle. They all act on scenes pre-designed in the Scenes tab.
Usually, only Show Scene and Destroy Scene will be
used, however sometimes it's useful for a scene to be created but not visible to
the user:
- by hiding a scene instead of completely destroying it, the settings of the elements
are retained for next time it is shown
- the values of the elements in the scene can be changed to track certain
events so that the scene can be immediately displayed when required without any
configuration
Scene Elements
Each scene is comprised of a number of elements.
An element has three main components:
Geometry
It's size and position on the screen. An element's geometry is specified in
the scene editor.
Content
How it looks on the screen.
Specified under the UI tab in the element editor. Some
elements also have a Background tab. A Menu element has an additional Items tab.
Event Tasks
What should happen when the user interacts with the element.
Specified under the right-most tabs after clicking on the element in the element editor.
There are different events depending on the type of element. For instance, a Button has
tap and long-tap events while a Slider has a value-set event.
Event tasks are run at priority one higher than the task which displayed the scene
Local variables set by event tasks are visible to all tasks in the same scene.
Scene Element Actions
In the Scenes action category, there are several actions for setting
the properties of scene elements. You can use these for a wide variety
of purposes e.g.
- when a slider value is set, change the zoom of an associated map element
- set the size of an element depending on current light level
- animate elements around a scene
Note that actions that affect scene elements can only be used when the scene has
already been created (via Create Scene or Show Scene).
The scene does not have to be visible.
Scene Edit
The scene editor is used for designing custom scenes.
The editor consists of three areas:
Display Area
The main part of the editor, where the position and size of elements are arranged.
The display area has two modes dependent on the setting of the magnifying glass icon in the corner.
Preview Mode
This mode shows the scene as it will appear when displayed.
- Click-and-drag on the edge of the scene to resize it
Editing Mode
This mode is zoomed to make editing easier.
- Long-click on an empty area to create a new element positioned there
- Long-click on an element to get options for the element
- Click on an element to edit it.
- Click-and-drag on the centre of an element to move it
- Click-and-drag on the edge of an element to resize it
When moving and resizing, the sides of elements are snapped to a grid to make alignment
easier. The grid size is unique to each scene and can be changed via Menu / Grid Size.
Tool Bar
Undo
Allows undo of all operations, up to 20 steps in the past.
New Element
Create a new element in the middle of the scene. Useful if the scene is already
cluttered with a lot of elements so there is no free space.
Touch Mode
There are three touch modes which decide the effect of taps on the
display area. Normal Mode is described above. Move Mode is intended to make it easier to reposition elements. Resize mode
is for making resizing easier.
Menu Options
Background Colour
A complex background can be set by long-tapping an element and specifying it as
the background element. If a uniform colour is sufficient, it can also
be specified with this menu option.
However, there is a special case where it's a good idea to specify a background colour even
if you already have a background element. A scene is resized to fit the container
into which it's placed, but in some cases (e.g. when it is shown as a full screen activity) there will be margins left on one
side of the container because the aspect ration of the scene
(the relative size of its width and height) of a scene is never changed. In such a
case, the margins are coloured with the background colour specified here.
Element Long-Click Options
Set Background
An element which is set as the scene background is resized to always fill the whole scene
and interferes less with selection of other elements. To reverse this, long-tap on it and
select Set Foreground.
Pin
When an element is positioned satisfactorily, it can be pinned to make it easier to
select and manipulate other elements. To reverse this, long-tap on it and select
Unpin.
Set Depth
Each element has a particular depth which is unique to it. Deeper elements are obscured
by shallower elements which overlap them.
Orientation
The geometry (position and size) of each element can be configured independently for
portrait and landscape display orientations by rotating the device to the desired
orientation in the editor.
If no geometry is configured for a particular orientation when the scene is displayed, Tasker will attempt to
fit the elements into the scene based on the geometry of the elements in the other orientation.
Scene Element: Button
About
A standard Android button enhanced to allow display of an icon, text or
both.
Parameter: Position
If both a Label and Icon are specified, the Position parameter refers to
the position of the Label. The Icon is then placed opposite the Label.
Events
Related Actions
See Also
The Element Editor screen.
Scene Element: Doodle
About
A Doodle is an image created by the user with a simple finger-painting
screen.
Click the Doodle parameter to edit the doodle.
Doodles are stored on external storage in the directory /sdcard/Tasker/cache/doodles
in case they are masterpieces which demand publishing.
Events
Related Actions
See Also
The Element Editor screen.
Scene Element: Image
Events
Related Actions
See Also
The Element Editor screen.
Scene Element: Oval / Rectangle
About
Shape elements are intended mostly for decoration but can also be used
as invisible 'launchpads' for e.g. stroke events.
Events
Related Actions
See Also
The Element Editor screen.
Scene Element: Map
About
A Map element is a view onto the same kind of map window used by Google Maps
but is much more automateable than the standalone app.
It's only possible to have one Map element per scene and Map elements
cannot appear in Overlay scenes.
Related Actions
Events
See Also
The Element Editor screen.
Scene Element: Menu
About
A menu displays a variable selection of items and can have a separate action, text and
icon defined for each item in the list.
Parameter: Source
Items can either be filled manually or from a variable array. In the case of an array,
the list shows all the items starting at the first index; %var(1) %var(2) etc.
In the case of manual specification, click on the Items tab in the element editor
to specify the items.
Parameter: Selection Mode
There are three selection modes:
- single: tapping an item deselects any other item selected
- multi: several items can be selected at the same time
- none: tapping an item never selects it
Selected items are highlighted. There are two ways to find out the selected
items:
- assign a task under the Item Tap element event tab. Every time an item is
tapped, the selected items are available in the local variable %select_indices
- query the selected items at any time using the action
Element Get Value
Parameter: Item Layout
Specifies how each item within the list will be displayed. Each item has exactly the same layout. To change the layout, click on it. Each Menu element has it's own unique item layout.
There are two pre-defined layouts you can choose from (click the magnifying glass icon). 'Icon and Text' is the default.
Events
Related Actions
Scene Element: Slider
About
A standard Android 'seek bar' enhanced to allow specification of the
thumb icon and display indicators for the min, max and current values.
Events
Related Actions
See Also
The Element Editor screen.
Scene Element: Text
About
Displays non-editable text for labels etc.
Parameter: Position
Where to place the text within its box
Parameter: Text Width Scale
A horizontal scaling factor to squash up
(negative values) or stretch (positive values) the text.
Parameter: Vertical Fit Mode
What to do when the height of the text to display is greater than
the height of the element.
Parameter: Text Format
Specifies how the text should be displayed.
- Plain Text
just show the text as-is
- Text With Links
things that look like links are clickable (though not in the scene editor) e.g. URLs, email addresses, phone numbers
- HTML
interpret the text as a piece of HTML. Only simple tags are interpreted and no images are displayable
Events
Related Actions
See Also
The Element Editor screen.
Scene Element: TextEdit
About
A standard Android box for text entry.
TextEdit elements cannot appear in Overlay scenes.
Parameter: Position
Where to place the text within its box
Parameter: Text Width Scale
Horizontal scaling factor to squash up (negative values) or stretch (positive values) the text.
Events
Related Actions
See Also
The Element Editor screen.
Scene Element: Web
About
A Web element is like a browser window.
Parameters: Mode / Source
These parameters determine how the content for the WebView is to be acquired.
- URI: the Source parameter refers to a URI
(e.g. http://) from which the WebView should retrieve content.
- File: the Source parameter contains a local
file path from which the WebView should retrieve content.
- Direct: the Source parameter directly specifies
the HTML and/or JavaScript content to load
Parameter: Allow Phone Access
If checked, the content in the WebView is allowed access to local device
data stores and can run JavaScript, including Tasker's JavaScript Interface functions.
This is a very powerful feature, since it allows a WebView to
present a complex and highly functional interface, but
should only be enabled if you entirely trust the source of
the specified content.
Parameter: Self Handle Links
If checked, links will be handled by the WebView itself, otherwise they
will be passed to the system for handling e.g. by the default web browser.
Events
Related Actions
See Also
The Element Editor screen.
Scene Element Edit
Allows configuration of the properties of a scene element. The different
types of property are divided into tabs.
Not all elements have all tabs.
UI
For the most part, configures the visual style of the element.
Items
Only relevant to Menu elements.
Each row configures an item in the menu. Starting from the left, the controls
are:
- selection checkbox
this is only present when Selection Mode is set to Single or Multi. It stipulates whether the item will be shown as selected when the menu is displayed.
- icon button
the icon to show for the item. If you don't want to show an icon, hide the icon element in the Layout parameter in the UI tab
- label text
the label to show for the item. If you don't want to show a label, hide the label element in the Layout parameter in the UI tab
- action button
an action to run when the item is tapped
- trash can
used to delete the item
To add an item, click the plus button at the bottom of the screen.
Background
Configures a rectangle shape to be used as the background for the element
when it is displayed. The background will be stretched to fit the size of
the element.
If you want to use an image for a background, create a separate Image element and
place it underneath.
Event Tabs
Event tabs stipulate what Tasker should do when the user interacts with the
element in some way. Most consist only of a task to specify but some
allow a filter specification so that the task only runs if the event matches
the filter.
To help the task to decide what to do with the event and to allow a single
task to handle many different events if desired, Tasker sets certain
local variables which give specific information about it. The variables
are easily accessible by clicking the usual variable tag icon in any action
in the task.
The following variables are available in all such tasks:
- %scene_name
the name of the scene containing the element
- %element_name
the name of the element that the user interacted with (e.g. Button1)
- %element_type
the type of element (e.g. Button)
- %event_type
the name of the event (e.g. Tap)
Text Changed
Elements: TextEdit
This event is triggered whenever the text changes e.g. because a
letter key has been pressed while the element had focus.
- %new_val
the new text
- %old_val
the old text
Tap, Long Tap
Elements: Button, Doodle, Image, Map, Oval, Rectangle, Text
In a Map element, the following variables are available:
- %coord
the latitute,longitude of the tapped location on the map
- %label
the label of the tapped GeoMarker (if any). You can add GeoMarkers to a Map element with the action Scene / Element Add GeoMarker
Value Selected
Elements: Slider
- %new_val
the new value of the element (e.g. 50)
- %old_val
the last selected value (e.g. 43)
Item Tap, Item Long Tap
Elements: Menu
- %select_indices
a comma-separated list of currently selected items in the list (e.g. 3,4)
- %select_labels
a comma-separated list of the labels of currently selected items in the list (e.g. Blue,Yellow)
- %tap_index
the index of the item that was tapped to cause this event (e.g. 3)
- %tap_label
the label of the item that was tapped to cause this event (e.g. Blue)
Stroke
Elements: Doodle, Image, Oval, Rectangle, Text
A stroke has two filter parameters.
- Direction
the direction from the start point of the stroke to the end point
- Length
minimum distance in (approximate) pixels from the start point of the stroke to the end point
If either of these parameters don't match the event, the task will not run.
- %stroke_dir
Direction, as described above
- %stroke_len
Length, as described above
Link Tap
Elements: WebView
A Link Tap has two filter parameters:
- URL
the URL of the tapped link. If entered, the tapped URL must match the entry (e.g. http://*.fruit.com) for the task to run
- Stop Event
whether to stop the WebView following the link
- %url
URL as described above
Page Loaded
Elements: WebView
- %url
the URL of the page (e.g. http://i.hate.fruit/except/mangos.html)
App Creation
Introduction
Tasker allows creation of completely standalone apps (APK files) which have no
requirement for Tasker to be installed on the device they're used on.
The intention is to allow people to create their own apps for fun, for sale
or just to share with friends. Or if you are concerned about all
the permissions Tasker needs you
can create an app that has only the permissions you require!
App creation is uncomplicated and takes only a few seconds once you're setup.
To create apps, you need the following on your device (not necessarily
on the device(s) the app will run on):
- Android 2.3+
- Tasker App Factory (free, see below)
- a device with an ARM or x86 processor (the vast majority of devices have one of those)
App creation is accessed by long-clicking on a project (not the base project) or task
and selecting Export then As App. Any
linked resources needed (e.g. other tasks, images) are included
as part of the new app.
To export anything except a single task, you need to create a project and put anything you
wish to export in the project.
Hello World Example
Let's make a simple app that just pops up Hello World! when it's launched. This example assumes that you are in Beginner Mode, please make sure that Menu / Prefs / UI / Beginner Mode is checked before you start.
1. Create A Task
- make a new task
click on the Tasks tab then click + to add a new task.
Give it a name Hello World.
- give the task an icon
long-click on the colourful icon in the bottom right and pick any icon
- add the Popup action
click + in the bottom left to add an action, select category Alert and then action Popup. Fill in Hello World! in the Text parameter, then click the accept button bottom left to accept the action, then again to accept the task.
- ask Tasker to create an app
long-click on the task you just made, select Export then As App. A popup appears mentioning a Missing App.
2. Install Tasker App Factory
To generate apps, Tasker needs a free helper app called Tasker App Factory.
It's available on Play Store and from the Tasker website.
Click the accept button on the popup to install the helper app.
3. App Generation
Tasker should now start generating your app, which will take maybe 12 seconds
depending on your device.
If all goes well, the Cancel button will turn into an OK button meaning
your app is ready!
We can't run the app straight away though because it hasn't been installed.
Click on the rightmost bottom button with the Android icon to ask Android
to install your app.
Once Android is done installing, you can click it's Open button to
run the app, or you can simply go to the home screen and click on the app's
icon in the launcher.
You should see a Hello World popup!
App Configuration
When in Beginner Mode, and if you only have one task to install,
Tasker will make guesses about how to configure the resulting app.
More usually, before an app is generated you will be presented
with a configuration screen which lets you specify various options
for the new app.
App Signing
Android requires that all apps be signed i.e. that they certify who
created them. By default, Tasker uses an automatically-generated
insecure certificate to sign apps and doesn't bother mentioning it.
However, if you want to release an app via a public site
(Play Store for example), you will need to sign it with a
proper (secure) certificate.
That's done so the site knows that it's you that's giving
them the app each time you submit a new version.
Certificates are kept in a keystore which is protected
with a password. To generate a keystore with a secure certificate,
use Menu / More / Developer Options / Create Certificate.
Once you've generated the keystore, Tasker will often need to
ask you for the certificate password before app generation so that
it can be used to sign each new version of your app.
Tasker makes an automatic backup of your keystore to
/sdcard/Tasker/factory/keystore.user
when it is first created and when you backup your profile data
with Menu / Data / Backup. It's highly advisable
to make a copy of that file and keep it safe away from your device.
Target Device Requirements
The device the child app is used on must meet the following requirements:
- have the Google Maps library installed, even if the exported project
or task does not use location in any way
- the minimum SDK version specified in the Kid Config screen
- have hardware corresponding to features specified in the Kid Config screen
Miscellaneous
Accessibility Service
Android accessibility support changed in Android 4.1 (JellyBean). If support is
needed for accessibility services in 4.1+, the Minimum Android Version in
the child Configuration screen must be set to 16 or higher. If support is required
pre-4.1, it must be set to less than 16.
In other words, to support both pre- and post-4.1 devices, two APKs must be
generated.
This applies to all features that rely on an Accessibility Service (events Notification, New Window, Button Widget Clicked, Notification Click, variables %NTITLE, %WIN)
Google Play Store allows publication of APKs targetting different Android versions
under the same package name, however this has not been tested by the developer
of Tasker.
Monitor Service
Most child apps include a service which constantly monitors for events. If you know that you don't need
to monitor events anymore (in-between app launches) you can use the Disable action in the Tasker category to
stop it.
It will be automatically started again next time the app is launched.
Widgets / Shortcuts
- it's not possible in Android to auto-create widgets with any app
- it's not possible *currently* to offer the user child-app widgets,
that may be available in the future to some extent
Memory Problems
If you are having low memory problems during app generation, you can ask
the App Factory to use external storage for the generation process.
See Menu / Prefs / More / Factory.
Preferences
The new app currently has the same default preferences as Tasker
with a couple of exceptions.
You can use the Set Tasker Pref action in the Tasker category
to change some of the preferences when the app is running.
Available Tasker Features
Obviously, the device the new app runs on may not have the same set of
available e.g. actions as the device the app is created on.
The Test action in the Misc category allows you to check
which Tasker features are available at run time (when the app
is being used).
Images
Referenced images (even scene doodles and photos from the SD card)
are bundled in with the app.
Plugins
When the new app is launched, it checks that all referenced plugins
are installed on the device and prompts the user to install missing ones.
Some plugins may not work on other devices if they themselves store something about the
action to be performed, since that data will not be available on the
other device.
Plugin authors: see also here.
JavaScript actions
Scripts referenced by a JavaScript action are packaged with the new app
and run directly from there.
SL4A Scripts
Scripts referenced in a Run Script action are packaged with the new
app and unpacked to /sdcard/sl4a/scripts, prefixed with the
package name, on first run. Tasker automatically inserts the WRITE_EXTERNAL_STORAGE
permission for that purpose.
If SL4A is missing on the target device, the new app will prompt the user
to download when launched.
If a new version of the app is reinstalled on the target device, the new versions
of the scripts will be written if the length has changed.
Other External Components
The following external components are also checked for on launch of the new app where
necessary:
- Speech engines (Say, Say After)
- APNDroid (Mobile Data APN)
- Zoom (Zoom action category actions)
- apps for 3rd Party actions
- apps for 3rd Party events
Maps
The data for Maps is provided by Google and they require a maps key for
each developer that uses it.
If you are using Map scene elements in your app, you will need to acquire a key
from Google that can be included with your app.
- [if necessary] setup a Google Account
- [if necessary] create a signing keystore
- get a fingerprint of your certificate:
Menu / More / Developer Options / Certificate Checksum
- fill in the fingerprint at Google's request page.
- in the App Configuration screen when generating your app, enter the map key in the relevant box. The box
will only be presented if your app uses one or more Map scene elements.
Variables
The new app is completely independent of Tasker, so it also does
not share any variable values.
Permissions
Tasker attempts to reduce the set of permissions required by the new app to
the smallest set required for the functionality it contains. For example,
no Vibrate permission will be requested if there is no vibrate action
used.
The WAKE_LOCK permission is unfortunately always required for technical reasons.
App Size
Generated apps are minimally around 640K but are unlikely to be
significantly larger unless a lot of images are referenced.
It's possible that this minimum can be reduced in the future.
Encryption
Code for encryption is included in any app created by App Factory, however
if you don't use encryption features it's unlikely to be a problem
in terms of export restrictions. However, that is an opinion, it is not legal advice.
Note that code libraries for encryption are included with every Android device. Tasker
(and child apps) use these libraries to perform the encryption, they do not contain
encryption code themselves.
Licence
You are free to distribute and sell apps created by Tasker in any
way you wish. No licence fees to the developer of Tasker are necessary.
It would be courteous to reference Tasker and it's website
(http://tasker.dinglisch.net) somewhere in your new app if possible.
Please note that use of images from some Ipacks in commercial software
is prohibited by the licence terms of the image creators. You will need
to contact the image designer to request their assent in such cases.
(the origin of an Ipack's images is displayed in the Ipack image selection
screen).
Tasker's builtin icons are mostly from the Crystal Project,
please check the licence terms on their website.
Task / Shortcut Widgets
The standard way of running a Tasker task is by attaching it to a profile
which performs it when the profile becomes active. However, tasks can
be directly assigned to icons on the home screen called Widgets or
Shortcuts.
Standard Widgets / Shortcuts
These consist of an icon (the Task icon) with a label (the Task name)
underneath, and look identical to the normal application icons
in the home screen.
Clicking on the icon runs the associated Task.
Task Timer Widgets
This type consists of an icon and label, like the standard widgets,
but also has a countdown timer display which counts down Days, Hours,
Minutes and Seconds.
When the timer expires (reaches 0) the associated Task is run.
Tapping on the icon of the widget shows a configuration
screen where the timer can be configured.
Tapping on the timer section of the widget will pause,
restart or reset the timer, depending on its current state.
Note that the timer updates more rarely when it is still a long
way from expiry in order to minimize power usage.
Creating a Widget / Shortcut
- Click and hold in an empty space on the Android home screen, until
a dialog appears.
- Select Widgets or Shortcuts
- Select Task or Task Timer (Widgets only)
- Pick an existing task or create a new one. When creating a new one, if
you do not expect to change the function of the widget/shortcut select
One-Time to avoid it cluttering your list of tasks.
- Use the Configuration Screen
to configure what should happen when the icon is clicked (or the timer
expires, in the case of a Task Timer widget). Take care to
select an appropriate name and icon for the task, as these will appear on
the home screen.
Changing a Widget / Shortcut
The function of widgets or shortcuts created from one-time tasks cannot be changed, it must be deleted and recreated.
On the other hand, if you associate a normal named task with a widget or shortcut then when the task is changed (via the Task Edit
screen) the function of the widget or shortcut also changes.
There are also some actions which will change the appearance of any widget:
- Tasker/Change Icon Set: changes the icon of a set of widgets to a different
style.
- Tasker/Set Widget Icon: changes the icon of a particular widget
- Tasker/Set Widget Label: changes the label of a particular widget
The latter two you could use to visually show the status of something e.g. WiFi.
Deleting a Widget / Shortcut
Click and hold on the icon in the Android home screen until the dustbin
icon appears. Drag the widget or shortcut icon to the dustbin icon and release.
Differences Between Widgets and Shortcuts
Advantages of Shortcuts
- they can be created in some places that widgets can't e.g. in home screen folders
- their layout probably better matches the default launcher layout
- long shortcut labels will scroll when selected in the default launcher
- they use slightly fewer system resources, though it's probably not noticeable
Advantages of Widgets
- they can use image files from SD for their icon
- their icon and label can be dynamically changed after creation
via the Set Widget Icon and Set Widget Label actions.
- timer widgets are possible
- they can be created without a label
So a shortcut should be used unless the extra configuration possibilities of a widget are necessary.
General
- you can create as many Tasker widgets and shortcuts as you like. You can even have several Timer widgets running at the same time.
- Timer Task widgets continue to update even when the screen is off.
Beginner Mode
When Tasker first starts, Beginner Mode is enabled.
In Beginner Mode, Tasker attempts to simplify things for inexperienced
users, mostly by UI elements which are unlikely to be needed by
inexperienced users.
Beginner Mode can be disabled by unchecking the option:
Menu / Prefs / UI / Beginner Mode
Some of the changes made in Beginner Mode are:
- main screen, Variables tab removed
- main screen, export options removed
- main screen, project tab not accessible
- task edit screen, task properties icon removed
- action edit screen, Label, Continue On Error parameters removed
- prefs screen, many options removed
In the userguide, when references are found to things which do not
appear on the screen. It's worth disabling Beginner Mode to see if that's
the problem.
CPU Control
Note: CPU control can damage your hardware e.g. by the CPU overheating. As for all Tasker
functions, you use it at your own risk!
General
On a rooted device (only) Tasker is able to control the CPU frequency of an Android device to some extent. This
is usually done either to save battery or make the device more responsive depending on the circumstances.
The relevant control action is CPU in the Misc category.
You can monitor the current state with the variables %CPUFREQ and %CPUGOV.
There are two aspects which can be controlled, the Frequency Range and the
CPU Governor. You will need to experiment with combinations of these to achieve the best results.
Frequency Range
You can set the minimum and maximum frequency which the CPU is allowed to run at. Only certain frequencies
are valid, depending on the CPU (click on the magnifying glass button to select a valid value).
The maximum frequency is probably initially set lower than the maximum frequency that the CPU can actually handle. If that is the case, you should be very cautious about setting it higher. Tasker will warn
you the first time you try to do configure an action to do that, assuming
you have not been using other apps to change the maximum frequency limit.
CPU Governor
The active governor decides what the CPU frequency should be set to at a particular time, within the frequency
range you have set. Each has it's own unique strategy. Here are the most common governors:
- Performance
keeps the CPU frequency always at the maximum. Most power-hungry, most responsive.
- Powersave
keeps the CPU frequency always at the minimum. Least power-hungry, least responsive.
- Ondemand
when the CPU is needed, immediately sets it to maximum frequency. Slowly reduces the
frequency back down to the minimum as time passes. Responsive, reasonable power usage.
- Interactive
like Ondemand, but more responsive with slightly more battery usage.
- Conservative
when the CPU load is needed, slowly increases the frequency to maximum. When the CPU is
no longer needed, immediately drops back to the minimum. Less power-usage than Ondemand or Interactive, less responsive.
Not all governors are available on all ROM versions. Your device may also have a governor not described here. You can still set that governor with Tasker.
CPU Action Not Available
Common problems are:
- root not recognized
Tasker decides that a device is rooted if /system/app/Superuser.apk is present and su is present in one of the directories of $PATH
- no available frequencies
Tasker needs to know what frequencies it can set the CPU to. It looks for the files /sys/devices/system/cpu/cpuX/cpufreq/scaling_available_frequencies, /sys/devices/system/cpu/cpuX/cpufreq/stats/time_in_state and /system/etc/scaling_available_frequencies (in that order). If you know what your CPU frequencies are, you could write them (space-separated, in numerical order) to the first (any number of CPUs) or last (1 CPU only) of those files.
Widget / Shortcut Configuration
This screen allows selection and configuration of a task which will be performed when an
icon is clicked on the Android home screen or a timer elapses.
Please read about Task Widgets / Shortcuts
before venturing further on this screen.
The layout of the Configuration screen is nearly identical to that of the
Task Edit screen. The
differences are as follows:
Flow Control
Overview
Task flow control is based on the following Tasker elements:
- variable values
- conditions on individual actions
- If / Else / Endif actions for conditional grouping of following actions
- For / End For to do a set of actions once for each of a set of elements
- Goto action (jumping around within a task).
- Perform Task action (calling other tasks as subroutines)
- Stop action (terminate task immediately)
On the Wiki there is a detailed example of
processing a file's content [External Link].
Tip: if you accidentally create a task that never ends when experimenting
with loops, use the Kill button in the Task Edit screen to end it
manually.
Conditions
Every action can have a condition associated with
it (specify this in the Action Edit screen). If the condition does not match,
the action will be skipped.
A condition consists of an operator ('equals' etc) and two parameters.
The possible operators are:
- Matches (~)
The right parameter is a pattern which the left parameter is matched against.
- Not Matches (!~)
As above, but the match must fail for the action to be executed.
- Less Than (<)
Both parameters (after variables are substitued) must be numbers or mathematical expressions and the first must be less than the second
e.g. 3 < 6. See Maths for more info.
- Greater Than (>)
As above, but the first parameter must evaluate to more than the second.
- Equals (=)
As above, but the two parameters must be numerically equal.
- Not Equals (!=)
As above, but the two parameters must be not numerically equal.
- Is/Isn't Set
Whether the specified variable has a value or not.
Expressions which are not mathematically valid e.g. I Am The Walrus > 5 give a warning and evaluate to false
when used with a mathematical operator.
Foreach Loop
Goal: perform a set of actions for each of apple, pear and banana.
| 1. | For %item apple,pear,banana |
Loop once for each of apple, pear and banana |
| 2. | Action One
|
Example: Flash %item |
| 3. | Action Two
|
... |
| 4. | End For
|
Return to action 1 if we havn't done all the items yet |
Result: Action One and Action Two are performed three times. The first time, the variable %item is set to apple, the second time pear and the last time banana.
You can insert a Goto action in the loop with either Top of Loop (meaning continue, skip to the next item straight away) or End of Loop (meaning break, stop without doing any more items) specified.
In adition to simple text, the For action accepts any comma-separated combination of these Items:
- a numeric range e.g. 1:5 (= 1,2,3,4,5)
- a numeric range with a jump e.g. 8:2:-2 (= 8,6,4,2)
- a numeric range defined by variable values e.g. 2:%end:%skip, 1:%arr(#)
- a variable name (which is replaced) e.g. %fruit (= banana maybe)
- a variable array part e.g. %arr(1:2) (= %arr1, %arr2 = apple,banana maybe)
A common case is to use %arr(), which performs a loop for each element in the array %arr.
For Loop
Goal: perform a set of actions for each of a range of numbers in turn.
Use the Foreach Loop as described above, with the Items parameter being a range specification e.g. 4:0, 100, 0:8:2 (= 4,3,2,1,0,100,0,2,4,6,8).
Until Loop
Goal: perform a Task X until some condition is met (at least once)
| 1. | Action One
|
... |
| 2. | Action Two
|
... |
| 3. | Goto 1
If %QTIME < 20 |
Return to action 1 if runtime < 20 |
Result: Action One and Action Two are performed until %QTIME contains the value 20 or more
i.e. until the task has been running for 20 seconds.
While Loop
Goal: perform a Task X while some condition is met.
| 1. | Stop
If %fruit Not Matches Apple |
Stop task if it's not crunchy, otherwise
go to next action |
| 2. | Action One
|
... |
| 3. | Action Two
|
... |
| 4. | Goto 1 |
Go back and see if we're still crunchy |
Result: Action One and Action Two are performed while %fruit contains the value Apple.
Counter Loop
Goal: perform a Task X a set number of times.
| 1. |
Variable Set %count, 0 |
Initialize the counter |
| 2. | Action One Label: LoopStart |
... |
| 3. | Action Two
|
... |
| 4. | Variable Add %count, 1 |
Add one to %count |
| 5. | Goto LoopStart
If %count < 10 |
Return to action 2 if count < 10 |
Result: after initialization of %count to 0, the task loops around the actions
from 2-5 until
%count reaches 10, at which point the condition on the Goto fails
and the end of the task is reached.
Note that we used a Goto to a labelled action this time. In
all but the very simplest tasks it's better to use a label rather than a number. It's easier to work out what's happening and if you insert or delete actions before the loop starts, the Goto will still jump to the right place.
An alternative way to do this loop is to use a For action specified as 0:10.
If / Then / Else Condition
Goal: perform certain Tasks if conditions are met, otherwise perform a
different task.
| 1. |
If
%fruit ~ Apple |
~ is short for 'matches' |
| 2. | Action One |
... |
| 3. | Action Two
|
... |
| 4. |
Else If
%fruit ~ Pear |
an Else action with a condition |
| 5. | Action Three |
... |
| 6. |
Else
|
|
| 7. | Action Four
|
... |
Result: actions One and Two are executed if %fruit matches Apple, Action Three is executed if %fruit matches Pear, otherwise Action Four is executed.
Notes:
- you can have as many
Else Ifs in a condition as you like
- if your condition is in the middle of a more complicated task, you need to tell Tasker where the condition ends with an
End If action
Subroutines
To call another task, use the Perform Task action. To use it as
a subroutine, you just need to ensure that the priority of the calling
task is less than the priority of the called task (more info:
scheduling).
The parent can optionally pass values to the child and receive a result back:
Parent Task
| 1. | Perform Task
Child,
Priority, 10
%par1, 5,
Result Value Variable, %result
|
pass 5 to the child, expect a result in %result |
| 2. | Variable Flash Result: %result
|
what did we get back ? |
Child Task
| 1. | Variable Set
%newval, %par1 + 1, Do Maths
|
add one to the value that was passed |
| 1. | Return
%newval
| set %result in the parent to the value of %newval in the child |
Result: the parent flashes 6
Notes:
- changes made to %par1 and %par2 in the child task are not reflected by their changing in the parent task
- receiving a return value is optional for the parent, even if the child tries to give it one
- unlike
Return statements in most computer languages, Tasker's does not necessarily stop the child task, so if the child and parent have the same priority they can both run together and the child return several results over time.
Encryption
Note: encryption functions are not available on the
Play Store version of Tasker due to US export restrictions.
Tasker has the ability to encrypt and decrypt files. The relevant
actions are in the Encryption action category.
Since decryption can be automated, you have the possibility to
keep data files encrypted outside of certain times, locations,
applications etc.
Warning: make backups of your files while setting up encryption
until you understand how the system works and are sure the
encryption/decryption process does not cause any corruption.
Tip: Tasker does not give progress reports while it's doing
encryption, if you want to know when an long decryption operation
is finished, just put a Vibrate action or similar after the
Encrypt/Decrypt action.
Keys
Tasker uses a system of named keys. All of the encryption
actions can specify a key name so that you can use different keys
with different files (if desired).
If no key name is specified, default is used.
Once a passphrase for a key is entered, the ciphers it generated are stored in memory
until explicitly deleted. The deletion might be specified after an Encrypt/
Decrypt File action, or explicitly with the Clear Key action.
Setting Up Encryption
General Preferences
First thing to do is check whether the encryption preferences for
Encryption Iterations and Encryption Algorithm are
as you wish. Once you start encryping things, it's time consuming
to start again with new encryption preferences.
The preferences can be found at Menu / Prefs / Action.
Be sure to have a look at the help text for each item.
Initial Encryption
To start with, you probably want to encrypt some files which are in
a particular directory, which you can then decrypt as they are needed.
To do that, create a task called Encrypt or similar
and add one or more Encrypt File or Encrypt Dir actions to it.
By default, the
key is cleared once the file is encrypted, so click 'Leave Key'
for all but the last action, otherwise you'll have to enter your
passphrase for each file.
Next, create a Tasker shortcut on the home screen, using the Encrypt
task. Tap the widget to encrypt your files. Notice how
you are only asked for the passphrase for the first one, because it
is stored until cleared.
The encrypted files will all receive an extension .tec
and the original files are deleted.
Decryption
Once you have a set of encrypted files, you need to setup the contexts
in which they will be decrypted.
Create another task called Decrypt or similar, and add Decrypt
actions to it to match the encrypt actions you setup previously.
Don't click Clear Key, otherwise you'll have to enter your
passphrase for every file (and at the start of encryption).
Now you can use your Encrypt and Decrypt tasks whenever you like. For instance,
you could create a profile with a Location Context and run your Decrypt task
when entering the location (assign Decrypt as the Enter task) and your Encrypt
task when leaving the location (assign Encrypt as the Exit task).
Important: when you use the Decrypt action, it recreates the original
file from the encrypted copy, but does not delete the encrypted version.
When you re-encrypt the file, if it has not changed it is simply deleted since we
already have an encrypted copy. If it has changed, it is re-encrypted.
The purpose of this method of operation is to:
- avoid the lengthy encryption process when unnecessary
- prevent accidental double-encryption (encrypting the same file twice)
Enter Key Action
It's not always convenient to enter the key at the point at which de- or encryption
takes place. This action allows you to specify the passphrase for a key
at a different point.
If you don't wish to double-enter a key when encrypting, you can also use this
action before an Encrypt action and not select Confirm.
Set Key Action
To allow full-automation of en/decryption, the passphrase for a key can also be set
without user interaction. However, this is much less secure tham Enter Key because:
- the passphrase (as part of the action) is stored in clear text in device memory and could be read by the root user if the device OS is compromised
- although the passphrase is itself encrypted when a backup is made to SD, the parameters for that encryption can be recovered from the java code in the Tasker apk file
Security
Algorithm
Tasker uses symmetric encryption, meaning the same passphrase is used both
to encrypt and decrypt the data.
The default algorithm is "PBEWithMD5And128BitAES-CBC-OpenSSL".
PBE stands for password-based encryption, see RFC 2898.
A salt is combined with the passphrase several hundreds of times using the MD5 algorithm
to produce a key which is used for the 128-bit (default setting) AES algorithm.
The number of iterations and algorithm can be set in Menu / Prefs / Action.
Pass Phrases
The longer the passphrase, the more secure the data. Minimally 8 characters of mixed
alphabetic, numeric and punctuation characters is recommended.
Clearing Keys
While a key's ciphers are in memory, anyone can use the key for
decryption or encryption if your device is lost or stolen, so it may be wise
to setup a Clear Key action e.g. when the device is turned off
(see Screen Off in the Event Context) or at a particular time (Time Context),
depending on what you are using the encryption for.
Manually Encrypting/Decrypting
You can use Tasker's file browser (action Browse Files) to encrypt/decrypt files
directly, via a long-click on the file.
Gestures & Shaking
General
Gestures are physical movements of the phone in space, which you first
record by creating a new Event of type Gesture (in the Misc category).
When you later redo the gesture while using your device, Tasker will carry out
the corresponding task(s) you have attached to its profile.
Like normal events, gestures are restricted by other contexts. For example,
if you define a profile with a Gesture (Event) and Application context, the
gesture will only be recognized while using that particular application.
Note: it might be a good idea to disable Tasker before setting up
new gestures, as otherwise you are likely to trigger previously defined ones.
Recording A Gesture
Gesture Points
First off, it's important to know that Tasker only records the particular points
(which we'll call inflection points) of a gesture that you tell it to.
For example, recording a gesture involving tilting the phone to the left and back
you would record three inflection points: the start, the tilted left position, and
the end (which is the same as the start in this case).
You can record as many points as you like, but in general it's best to record
only the points where the phone is not moving.
Recognized Movements
Tasker will only recognize changes in the angle of the phone i.e.
tilting to left or right, backwards or forwards, or rotating vertically.
Imagine three poles going through the device in the three dimensions.
Moving the phone backwards or forwards, up or down or side to side cannot
be recognized.
Procedure
- create a new Gesture Event and give it a name (so you can differentiate between
different gestures).
- put the phone in the position where you want the gesture to
start and press-and-hold the Call, Camera, Menu, Search or Volume hardware buttons
to record the point. The device will buzz.
- move to another (preferably not-moving) point on the path of your gesture, and
press the button again (not a long press). The device will buzz.
- on the final inflection point, press-and-hold the button
to mark the end of the gesture. The device will buzz again and the "Recorded."
message should now flash up.
- Press Done, and add a Vibrate action so you can hear when your
pattern matches when testing it.
Activation
Calibration
Before trying to match a pattern, you probably need to calibrate the hardware
in your device. Go to Menu / Prefs / Monitor / Gestures. Press
the Calibrate button and tilt your phone around in all directions.
Tasker now has some idea what kind of values the accelerometer in your
phone produces.
You only need to calibrate once.
Matching
Now exit Tasker and move your device through the points you previously defined
when recording. You should hear the device vibrate when it reaches the final
recorded point.
If not, try playing with the values in the Gesture Settings screen. For instance,
you could try raising the Match Radius (but be careful not to raise it too much
or you'll get a lot of matches by mistake).
Power Usage
Tasker does its best to limit power usage of gesture monitoring.
- monitoring for gestures only takes place when all the
other contexts in a profile are already active (and so the gesture might
have a chance of activating the profile). For example, if you combine an
Application and Gesture (Event) context, gesture monitoring will only
take place while using that particular application.
- Gesture monitoring is by default turned off when the display is off unless a power source is connected to the device,
unless specified otherwise in
Menu / Prefs / Monitor / Display Off Monitoring
- updates from the accelerometer are at the minumum rate until the start of a gesture is detected.
Icons
Tasker can use four categories of icons:
Application,
Built-In,
Ipack,
User-Installed.
In some places it's also possible to use any image stored on local media as an icon.
Application Icons
These are taken from applications installed on the device.
Minor note: if the icon of the application changes, an update of previously created widgets/shortcuts can
be forced by creating a single widget with the new icon and then rebooting.
Built-In Icons
These come with Tasker and are kept in the device's memory.
Ipack Icon Sets
Ipack is a free, open format for sharing of icon sets between Android applications.
Ipack icon sets can be either installed from Play Store or from the Ipack website.
When setting an icon, you will notice an item labelled Download More Icons. Clicking on it will use the appropriate source depending on which version of Tasker you have.
User-Installed Icons
You can also install your own icons directly into Tasker's icon directory
/sdcard/Tasker/.icn/. Make sure the icons are in a subdirectory.
The subdirectory should also only be one level deep (no subsubdirectories).
Icons must be in PNG format.
Example: a two-icon set called Christmas would have the two files
in these locations:
/sdcard/Tasker/.icn/Christmas/santa.png
/sdcard/Tasker/.icn/Christmas/snowman.png
JavaScript Support
Introduction
Tasker supports running JavaScript code in tasks or WebView scene elements.
Most Tasker actions can be accessed direct from the JavaScript.
JSON and XMLHTTPRequest are also directly available from the JavaScript code.
JavaScript in Tasks
JavaScript can be embedded inline in tasks via the JavaScriptlet (direct
specification of JavaScript to run) or JavaScript (load script from file)
actions.
In both cases, the JavaScript executes in sequence with the other actions in the task
and variables are transparently converted so pieces of JavaScript can be
interwoven throughout the task.
Embedded in HTML
WebView elements allow specification of mixed HTML and JS for the element
content.
<H1 onClick="setWifi( false )">ClickMeToTurnOffWifi</H1>
This allows a single WebView to present a complete user-interface.
Local Variables
In JavaScript(let) actions, local variables (all lower case, e.g. %myvar) are directly accessible in the JavaScript without
the % sign (e.g. myvar). If the script changes the value, the new value is transparently
used by subsequent actions in the task.
In JavaScript embedded in HTML, the functions local and
setLocal must be used to access variables local to the scene hosting the WebView.
Global Variables
Tasker global variables need to be accessed via global() and set via setGlobal().
Arrays
Local Tasker arrays are transparently available in Javascript(let)s and vice-versa.
They are not available in WebViews.
Arrays which are not existing Tasker arrays must be declared in the JS as such i.e. in
this case arr will not be visible to the remainder of the task:
var arr = getSomeArray();
Whereas in this case it will:
var arr = [];
arr = getSomeArray();
Note that:
- JavaScript array indices start at 0, whereas Tasker array indices start at 1
- JavaScript uses
[] while Tasker uses ()
So, for example, %arr(1) (Tasker) is equivalent to arr[0] (JavaScript).
Settings
Unlike normal Tasker actions, settings which are changed in JavaScript as part of a profile's
enter task are not restored when the profile exits.
Execution
Execution Instances
Only one script can execute at one time. Once a piece of
JavaScript is executing, it cannot be interrupted by another
piece.
Working Off-Device
You might wish to develop long and/or complicated tasks off-device e.g. on a PC.
There are two strategies for that:
1. JavaScript action
For off-device testing, use Menu / More / Developer / Save JS Library Template to get dummy
definitions for the built in functions. Include that file when developing on your PC.
To test in your JavaScript code whether you're on-device or not, use
var onAndroid = ( global( 'sdk' ) > 0 );
By using the JavaScript action rather than JavaScriptlet you can easily
access a file synced from PC to a file on the Android device.
2. Using WebView
If you specify a website URL as the content for your WebView, then testing the
code on the target device is a simple matter of pushing the new version to your webserver and
reloading the WebView on the device (see action Element Web Control)
Builtin Function Execution
Calls to most Tasker builtin functions (see below) are
executed as normal single-action tasks and thus may be blocked
by other executing tasks.
They execute at the priority of the task that executed the JavaScript
plus two.
JavaScript(let): Alert,Confirm,Prompt
Scripts using these functions require a 'user-interface' and may cause
interference with the currently running app (though in most cases they
will not).
JavaScript(let): Auto Exit
By default, the JavaScript(let) action will end when the main execution
sequence is finished.
If you are using asynchronous code e.g. via setTimeout() or other callbacks,
you should deselect Auto Exit. You are then responsible yourself for telling
Tasker to continue the task by calling exit().
In any case, execution will stop when the timeout configured for the action is reached.
JavaScript(let): Libraries
You can specify as many libraries as you want in the Libraries parameter,
separated by newlines.
Several popular libraries are pre-selectable.
You may wish to download them manually to your local storage and change the http URL
to a file URL so that Internet is not required to run your script.
Important: if you are using your own libraries developed on Windows, you may need to convert
CRLF style line endings to Unix style LF.
Builtin Functions
Tasker makes most of it's actions available via functions which can be called directly via name
in JavaScript(let) actions and WebView elements.
Exception: in WebView content where mode is set to URL, the functions must be prefixed by tk e.g. tk.flash('Woo!')
alarmVol / btVoiceVol / callVol / dtmfVol / mediaVol / notificationVol / systemVol / ringerVol
var ok = alarmVol( int level, bool display, bool sound )
Set the relevant system volume to level.
If display is true, the new level will be flashed up on-screen.
If sound is true, a tone will sound at the new level.
audioRecord
var ok = audioRecord( str destPath, str source, str codec, str format )
- destPath: where to put the recording. Note that a file extension is not
necessary, it will correspond to the selected format.
- source: def, mic, call, callout or callin
- codec: amrn, amrw or aac
- format: mp4, 3gpp, amrn, amrw or amrr
The JavaScript does not wait for the audio recording to complete.
See also: audioRecordStop().
audioRecordStop
var ok = audioRecordStop()
Stop recording previously initiated by audioRecord().
browseURL
var ok = browseURL( str URL )
Open the default browser at the specifed URL.
button
var ok = button( str name )
Simulate a press of the named button.
name must be one of back, call, camera, endcall, menu, volup, voldown or search.
This function requires a rooted device.
call
var ok = call( str num, bool autoDial )
Make a phone call.
If autoDial is false, the phone app will be brought up with
the number pre-inserted, if true the number will also be dialed.
callBlock
var ok = callBlock( str numMatch, bool showInfo )
Block outgoing calls matching numMatch.
If showInfo is set, Tasker will flash a message when
a call is blocked.
callDivert
var ok = callDivert( str fromMatch, str to, bool showInfo )
Divert outgoing calls matching fromMatch
to the number to.
If showInfo is set, Tasker will flash a message when
a call is diverted.
callRevert
var ok = callRevert( str numMatch )
Stop blocking or diverting outgoing calls previously specified with
callBlock or callDivert.
carMode
var ok = carMode( bool onFlag )
Turn on or off Android Car Mode.
clearKey
var ok = clearKey( str keyName )
Clear the passphrase for the specified keyName.
See Also: Encryption in the Userguide.
composeEmail
var ok = composeEmail( str to, str subject, str message )
Show an email composition dialog with any specified fields pre-filled.
The JavaScript does not wait for the email to be sent before continuing.
composeMMS
var ok = composeMMS( str to, str subject, str message, str attachmentPath )
Show an MMS composition dialog with any specified fields pre-filled.
The JavaScript does not wait for the MMS to be sent before continuing.
composeSMS
var ok = composeSMS( str to, str message )
Show an SMS composition dialog with any specified fields pre-filled.
The JavaScript does not wait for the SMS to be sent before continuing.
convert
var result = convert( str val, str conversionType )
Convert from one type of value to another.
conversionType must be one of: byteToKbyte,
byteToMbyte, byteToGbyte, datetimeToSec, secToDatetime, secToDatetimeM, secToDatetimeL, htmlToText,
celsToFahr, fahrToCels, inchToCent, metreToFeet, feetToMetre, kgToPound, poundToKg, kmToMile,
mileToKm, urlDecode, urlEncode, binToDec, decToBin, hexToDec, decToHex, base64encode base64decode,
toMd5, toSha1, toLowerCase, toUpperCase, toUpperCaseFirst.
See also: action Variable Convert.
createDir
var ok = createDir( str dirPath, bool createParent, bool useRoot )
Create the named dirPath. If createParent is specified and any
parent directory does not exist, it will also be created.
If useRoot is specified, the operation will be performed as the root user
(where available).
createScene
var ok = createScene( str sceneName )
Create the named scene without displaying it.
cropImage
var ok = cropImage( int fromLeftPercent, int fromRightPercent, int fromTopPercent, int fromBottomPercent )
Crop an image in Tasker's image buffer previously loaded via loadImage.
decryptDir
var ok = decryptDir( str path, str key, bool removeKey )
As decryptFile(), but decrypts each file in the specified directory
in turn.
decryptFile
var ok = decryptFile( str path, str key, bool removeKey )
Decrypt the specified file using the encryption parameters specified in Menu / Prefs / Action.
If removeKey is not set, the entered passphrase will be reapplied automatically to the
next encryption/decryption operation with the specified keyName.
See Also: Encryption in the Userguide,
Decrypt File action.
deleteDir
var ok = deleteDir( str dirPath, bool recurse, bool useRoot )
Delete the named dirPath. recurse must be specified if
the directory is not empty.
If useRoot is specified, the operation will be performed as the root user
(where available).
deleteFile
var ok = deleteFile( str filePath, int shredTimes, bool useRoot )
Delete the named filePath.
shredTimes has range 0-10.
If useRoot is specified, the operation will be performed as the root user
(where available).
See also: action Delete File
destroyScene
var ok = destroyScene( str sceneName )
Hide the named scene if it's visible, then destroy it.
displayAutoBright
var ok = displayAutoBright( bool onFlag )
Whether the display brightness should automatically adjust to the ambient light or not.
displayAutoRotate
var ok = displayRotate( bool onFlag )
Whether the display orientation should change based on the physical orientation of the device.
displayTimeout
var ok = displayTimeout( int hours, int minutes, int seconds )
How long the period of no-activity should be before the display is turned off.
dpad
var ok = dpad( str direction, int noRepeats )
Simulate a movement or press of the hardware dpad (or trackball).
direction must be one of up, down, left, right or press.
This function requires a rooted device.
enableProfile
var ok = enableProfile( str name, boolean enable )
Enable or disable the named Tasker profile.
encryptDir
var ok = encryptDir( str path, str keyName, bool rememberKey, bool shredOriginal )
As encryptFile(), but encrypts each file in the specified directory
in turn.
elemBackColour
var ok = elemBackColour( str scene, str element, str startColour, str endColour )
Set the background colour of the specified scene element.
See also: action Element Back Colour.
elemBorder
var ok = elemBorder( str scene, str element, int width, str colour )
Set the border colour and width of the specified scene element.
elemText
var ok = elemText( str scene, str element, str position, str text )
Set the text of the specified scene element.
pos must be one of repl (replace existing text completely), start
(insert before existing text) or end (append after existing text).
See also: action Element Text.
elemTextColour
var ok = elemTextColour( str scene, str element, str colour )
Set the text colour of the specified scene element.
See also: action Element Text Colour.
elemTextSize
var ok = elemTextSize( str scene, str element, int size )
Set the text size of the specified scene element.
See also: action Element Text Size.
elemVisibility
var ok = elemVisibility( str scene, str element, boolean visible, int animationTimeMS )
Make the specified scene element visible or invisible.
See also: action Element Visibility.
endCall
var ok = endCall()
Terminate the current call (if there is one).
encryptFile
var ok = encryptFile( str path, str keyName, bool rememberKey, bool shredOriginal )
Encrypt the specified file using the encryption parameters specified in Menu / Prefs / Action.
If rememberKey is set, the entered passphrase will be reapplied automatically to the
next encryption/decryption operation with the specified keyName.
If shredOriginal is specified, the original file will be overwritten several
times with random bits if encryption is successful.
See Also: Encryption in the Userguide,
Encrypt File action.
enterKey
var ok = enterKey( str title, str keyName, bool showOverKeyguard, bool confirm, str background, str layout, int timeoutSecs )
Show a dialog to enter the passphrase for the specified keyName. The JavaScript waits
until the dialog has been dismissed or the timeout reached.
- confirm: if set, the passphrase must be entered twice to ensure it is correct.
- background: [optional] a file path or file URI to a background image.
- layout: the name of a user-created scene to use in place of the built-in scene.
See Also: Encryption in the Userguide
filterImage
bool ok = filterImage( str mode, int value )
Filter an image previously loaded into Tasker's image buffer via
loadImage()
Possible values of mode are:
- bw: convert to black & white, using value as a threshold
- eblue: enhance blue values by value
- egreen: enhance green values by value
- ered: enhance red values by value
- grey: convert to greyscale, value is unused
- alpha: set pixel alpha (opposite of transparency) to value
value should be 1-254.
flipImage
bool ok = flipImage( bool horizontal )
Flip an image previously loaded into Tasker's image buffer via
loadImage()
If horizontal is false, the image is flipped vertically.
exit
exit()
Stop execution of the JavaScript.
flash
flash( str message )
Flash a short-duration Android 'Toast' message.
flashLong
flashLong( str message )
Flash a long-duration Android 'Toast' message.
getLocation
var ok = getLocation( str source, bool keepTracking, int timeoutSecs )
Try to get a fix of the current device location.
source must be one of gps, net or any.
If keepTracking is set, the specified source(s) will be left tracking
with the purpose of providing a much quicker fix next time the function is
called.
Fix coordinates are stored in the global Tasker variables %LOC (GPS) and/or %LOCN (Net).
The value can be retrieved with the global function. Several other
parameters of the fix are also available, see Variables.
Example
var lastFix = global( 'LOC' );
if (
getLocation( 'gps' ) &&
( global( 'LOC' ) != lastFix )
) {
flash( "New fix: " + global( 'LOC' ) );
}
See also: action Get Location, function stopLocation.
getVoice
str result = getVoice( str prompt, str languageModel, int timeout )
Get voice input and convert to text.
result is 'undefined' if the voice acquisition failed, otherwise
it's an array of possible matching texts.
prompt is a label for the dialog that is shown during voice acquisition.
languageMode gives the speech recognition engine a clue as to the
context of the speech. It must be one of web for 'web search' or
free for 'free-form'.
goHome
goHome( int screenNum )
Go to the Android home screen. screenNum is not supported by all
home screens.
haptics
var ok = haptics( bool onFlag )
Enable/disable system setting Haptic Feedback.
hideScene
var ok = hideScene( str sceneName )
Hide the named scene if it's visible.
global
var value = global( str varName )
Retrieve the value of a Tasker global variable. Prefixing the name with % is optional.
listFiles
str files = listFiles( str dirPath, bool hiddenToo )
List all files in the specified dirPath.
files is a newline-separated list of subfiles.
If hiddenToo is specified, files starting with period are
included, otherwise they are not.
Example:
var files = listFiles( '/sdcard' );
var arr = files.split( '\n' );
flash( 'Found ' + arr.length + ' files' );
loadApp
var ok = loadApp( str name, str data, bool excludeFromRecents )
Start up the named app.
Name can be a package name or app label, it's tested first against
known package names. Note: app label could be localized to another
language if the script is used in an exported app.
Data is in URI format and app-specific.
When excludeFromRecents is true, the app will not appear in the home screen
'recent applications' list.
loadImage
var ok = loadImage( str uri )
Load an image into Tasker's internal image buffer.
The following uri formats are currently supported:
- file:// followed by a local file path
See also Load Image action.
lock
var ok = lock( str title, str code, bool allowCancel, bool rememberCode, bool fullScreen, str background, str layout )
Show a lock screen, preventing user interaction with the covered part of the screen. The JavaScript waits until the
code has been entered or the lock cancelled (see below).
- code: the numeric code which must be entered for unlock
- allowCancel: show a button to remove the lockscreen, which causes a return to the Android home screen
- rememberCode: the code will be remembered and automatically entered when the lock screen is show in future,
until the display next turns off
- background: [optional] a file path or file URI to a background image.
- layout: the name of a user-created scene to use in place of the built-in lock scene
local
var value = local( str varName )
Retrieve the value of a Tasker scene-local variable. Prefixing the name with % is optional.
This function is only for use by JavaScript embedded in HTML and accessed via
a WebView scene element.
mediaControl
var ok = mediaControl( str action )
Control media via simulation of hardware buttons.
Possible actions are next, pause, prev, toggle or stop.
micMute
var ok = micMute( bool shouldMute )
Mute or unmute the device's microphone (if present),
mobileData
var ok = mobileData( bool set )
Enable or disable the system Mobile Data setting.
See also: action Mobile Data
musicBack
var ok = musicBack( int seconds )
Skip back by seconds during playback of a music file previously started by musicPlay.
See also: musicSkip, musicStop
musicPlay
var ok = musicPlay( str path, int offsetSecs, bool loop, str stream )
Play a music file via Tasker's internal music player.
stream to which audio stream the music should be played
This function does not not wait for completion.
The last 3 arguments may be ommitted, in which case they default to 0,
false and media respectively.
See also: musicStop, musicBack,
musicSkip
musicSkip
var ok = musicSkip( int seconds )
Skip forwards by seconds during playback of a music file previously started by musicPlay.
See also: musicBack, musicStop
musicStop
var ok = musicStop()
Stop playback of a music file previously started by musicPlay.
See also: musicBack, musicSkip
nightMode
var ok = nightMode( bool onFlag )
Turn on or off Android Night Mode.
popup
var ok = popup( str title, str text, bool showOverKeyguard, str background, str layout, int timeoutSecs )
Show a popup dialog. The JavaScript waits until the popup has been dismissed or the timeout reached.
- background: [optional] a file path or file URI to a background image.
- layout: the name of a user-created scene to use in place of the built-in popup scene.
performTask
var ok = performTask( str taskName, int priority, str parameterOne, str parameterTwo )
Run the Tasker task taskName.
Note that the JavaScript does not wait for the task to complete.
profileActive
bool active = profileActive( str profileName )
Whether the named Tasker profile is currently active. Returns false if
the profile name is unknown.
pulse
bool ok = pulse( bool onFlag )
Enable or disable the Android Notification Pulse system setting.
readFile
var contents = readFile( str path )
Read the contents of a text file.
reboot
var ok = reboot( str type )
Reboot the device.
type is one of normal, recovery or bootloader.
It can be ommitted and defaults to normal.
Requires a rooted device.
See also: function shutdown
resizeImage
var ok = resizeImage( int width, int height )
Scale the current image in Tasker's image buffer to the specified dimensions.
rotateImage
var ok = rotateImage( str dir, int degrees )
Rotate the current image in Tasker's image buffer.
dir must be one of left or right.
degrees must be one of 45, 90, 135 or 180.
saveImage
var ok = saveImage( str path, int qualityPercent, bool deleteFromMemoryAfter )
Save the current image in Tasker's image buffer to the specified file path.
Save Image action.
say
var ok = say( str text, str engine, str voice, str stream, int pitch, int speed )
Cause the device to say text out loud.
- engine: the speech engine e.g. com.svox.classic Defaults to the system default.
- voice: the voice to use (must be supported by engine). Defaults to the current system language.
- stream: to which audio stream the speech should be made
- pitch: 1-10
- speed: 1-10
The script waits for the speech to be finished.
sendIntent
var ok = sendIntent( str action, str targetComp, str package, str class, str category, str data, str mimeType, str[] extras );
Send an intent. Intents are Android's high-level application interaction system.
Any parameter may be specified as undefined.
- targetComp: the type of application component to target, one of receiver, activity or service.
Defaults to receiver.
- package: the application package to limt the intent to
- class: the application class to limit the intent to
- category: one of none, alt, browsable, cardock, deskdock, home, info, launcher, preference, selectedalt, tab or test,
defaults to none
- extras: extra data to pass, in the format key:value. May be undefined. Maximum length 2.
See also: action Send Intent.
sendSMS
var ok = sendSMS( str number, str text, boolean storeInMessagingApp );
Send an SMS.
See also: action Send SMS
setAirplaneMode
var ok = setAirplaneMode( bool setOn )
Enable or disable Airplane Mode.
Get the current value with:
var enabled = global( 'AIR' );
See also: function setAirplaneRadios
setAirplaneRadios
var ok = setAirplaneRadios( str disableRadios )
Specify the radios which will be disabled when the device enters
Airplane Mode.
disableRadios is a comma-separated list with radio names from
the following set: cell, nfc, wifi, wimax, bt.
Get the current value with:
var radios = global( 'AIRR' );
See also: function setAirplaneMode
setAlarm
var ok = setAlarm( int hour, int min, str message, bool confirmFlag )
Create an alarm in the default alarm clock app.
confirmFlag specifies whether the app should confirm that the alarm has been set.
message is optional.
Requires Android version 2.3+.
setAutoSync
var ok = setAutoSync( bool setOn )
Enable or disable the global auto-sync setting.
scanCard
var ok = scanCard( str path )
Force the system to scan the external storage card for new/deleted media.
If path is defined, only that will be scanned.
See also: action Scan Card
setBT
var ok = setBT( bool setOn )
Enable or disable the Bluetooth radio (if present).
Test BT state with:
if ( global( 'BLUE' ) == "on" ) { doSomething(); }
setBTID
var ok = setBTID( str toSet )
Set the bluetooth adapter ID (the name as seen by other devices).
setGlobal
setGlobal( str varName, str newValue )
Set the value of a Tasker global user variable. Prefixing varName with % is optional.
setKey
var ok = setKey( str keyName, str passphrase )
Set the passphrase for the specified keyName.
See Also: Encryption in the Userguide.
setLocal
setLocal( str varName, str newValue )
Set the value of a Tasker scene-local user variable. Prefixing varName with % is optional.
This function is only for use by JavaScript embedded in HTML and accessed via
a WebView scene element.
setClipboard
var ok = setClipboard( str text, bool appendFlag )
Set the global system clipboard.
Test the value with:
var clip = global( 'CLIP' );
settings
var ok = settings( str screenName )
Show an Android System Settings screen.
screenName must be one of all, accessibility, addacount, airplanemode,
apn, app, batteryinfo, appmanage
bluetooth, date, deviceinfo, dictionary, display, inputmethod, internalstorage,
locale, location, memorycard, networkoperator, powerusage, privacy, quicklaunch,
security, mobiledata, search, sound, sync, wifi, wifiip or wireless.
setWallpaper
var ok = setWallpaper( str path )
Set the system home screen wallpaper.
setWifi
var ok = setWifi( bool setOn )
Enable or disable the Wifi radio (if present).
Test wifi state with:
if ( global( 'WIFI' ) == "on" ) { doSomething(); }
shell
var output = shell( str command, bool asRoot, int timoutSecs )
Run the shell command command.
asRoot will only have effect if the device is rooted.
output is 'undefined' if the shell command failed. It's maximum size is
restricted to around 750K.
showScene
var ok = showScene( str name, str displayAs, int hoffset, int voffset, bool showExitIcon, bool waitForExit )
Show the named scene, creating it first if necessary.
- displayAs: options:
Overlay, OverBlocking, OverBlockFullDisplay, Dialog, DialogBlur, DialogDim,
ActivityFullWindow, ActivityFullDisplay, ActivityFullDisplayNoTitle
- hoffset, voffset: percentage vertical and horizontal offset for the scene -100% to 100% (not relevant for
full screen/window display types)
- showExitIcon: display a small icon in the bottom right which destroys the scene when pressed
- waitForExit: whether to wait for the scene to exit before continuing the script
shutdown
var ok = shutdown()
Shutdown the device.
Requires a rooted device.
See also: reboot
silentMode
var ok = silentMode( str mode )
Set the system silent ('ringer') mode.
mode must be one of off, vibrate or on
sl4a
var ok = sl4a( str scriptName, boolean inTerminal )
Run a previously created SL4A script.
soundEffects
var ok = soundEffects( bool setTo )
Setting the system Sound Effects setting (sound from clicking on
buttons etc.
speakerphone
var ok = speakerPhone( bool setFlag )
Enable or disable the speakerphone function.
statusBar
var ok = statusBar( bool expanded )
Expand or contract the system status bar.
stayOn
var ok = stayOn( str mode )
Specify whether the device should remain on when power is connected.
Possible modes are never, ac, usb, any.
stopLocation
var ok = stopLocation()
Stop tracking a location provider. This is only relevant when a getLocation
function has been previously called with the keepTracking parameter set.
systemLock
var ok = systemLock()
Turn off the display and activate the keyguard.
Requires Tasker's Device Administrator to be enabled in Android settings.
taskRunning
bool running = taskRunning( str taskName )
Whether the named Tasker task is currently running. Returns false if
the task name is unknown.
takeCall
bool ok = takeCall();
Auto-accept an incoming call (if there is one).
takePhoto
bool ok = takePhoto( int camera, str resolution, str filePath, bool insertGallery )
Take a photo with the builtin camera.
- camera: 0 = rear camera, 1 = front camera
- resolution: format WxH e.g. 640x840
- filePath: see here
- insertGallery: whether to insert the resulting picture in the Android Gallery application
type
var ok = type( str text, int repeatCount )
Simulate keyboard typing.
Requires a rooted device.
unzip
boolean ok = unzip( str zipPath, bool deleteZipAfter )
Unpack a Zip archive into the parent directory of the archive.
deleteZip causes the zip archive to be deleted after successful
unpacking.
usbTether
usbTether( bool set )
Enable or disable USB tethering.
See also: action USB Tether
vibrate
vibrate( int durationMilliseconds )
Cause the device to vibrate for the specified time.
vibratePattern
vibratePattern( str pattern )
Cause the device to vibrate following the specified pattern, which
consists of a sequence of off then on millisecond durations e.g.
500,1000,750,1000
wait for 500ms, vibrates 1000ms, wait for 750ms, then vibrate for 1000ms.
wait
wait( int durationMilliseconds )
Pause the script for the specified time.
Warning: may cause some preceeding functions not to complete in some situations.
If in doubt, use JavaScript setTimeout() instead.
wifiTether
var ok = wifiTether( bool set )
Enable or disable Wifi tethering.
See also: action Wifi Tether
writeFile
var ok = writeFile( str path, str text, bool append )
Write text to file path.
If append is specified, the text will be attached to the
end of the existing file contents (if there are any).
zip
boolean ok = zip( str path, int level, bool deleteOriginalAfter )
Zip a file or directory.
level is the desired compression level from 1-9, with 9 resulting
in the smallest file and the longest compression time.
deleteOriginal causes path to be deleted if the zip operation
is successful.
Notes
Audio Streams
Must be one of call, system, ringer, media, alarm or notification
Colours
Colours are specified in AARRGGBB hexadecimal format, with solid white being FFFFFFFF.
File Paths
File paths can be specified as either absolute (start with /) or
relative (don't start with /).
Relative file paths are relative to the root of the external storage media
(usually SD). So, for example, pics/me.jpg might resolve
to /sdcard/pics/me.jpg.
Location Without Tears
This is an overview guide to choosing a method for fixing your location with Tasker. At the end are
some advanced power-saving strategies.
Power / Accuracy Comparison
More stars mean higher power usage or higher accuracy (Acc).
Detail Comparison
State: Cell Near
Setup
Create a state context, select Phone then Cell Near. Click Update and walk around a bit to scan for cell towers nearby.
About
Uses information about the cell towers the phone uses for telephony to record and match a location.
When the display is off, frequency of checks is controlled by Menu / Prefs / Monitor / Display Off All Checks.
If your profile keeps deactivating, go back to the Cell Near state and click the magnifying glass icon to check
for cells you may have missed in your scan.
Plus / Minus
- (+) virtually no extra power on top of power needed for normal phone service
- (+) when the display is on, context updates as soon as the tower is visible
- (+) when the display is off, only one check period is needed to determine context exit
- (-) highly inaccurate
- (-) must be physically at the location in order to record it
Location: Net
Setup
Create a location context, and deselect GPS.
About
Net location accuracy varies greatly. It's very important that you create a large radius around
the spot you wish to detect.
Frequency of checks is controlled by Menu / Prefs / Monitor / Network Location Check (screen on)
and Menu / Prefs / Monitor / Display Off All Checks.
More Info.
Plus / Minus
- (+) extremely low (extra) power (IF network is available anyway)
- (-) requires network and phone service
- (-) highly inaccurate and variable fixes
Location: Net & Wifi
Setup
Create a location context and deselect GPS. Make sure your device's Wifi is turned on
when you want a more accurate location fix.
About
Net location can be assisted by nearby access points when Wifi is turned on (Google has
a map of APs for many areas).
Turn Wifi off when not needed to conserve power e.g. use a Time context to turn wifi off at night.
Plus / Minus
- (+) very good accuracy in built-up areas for relatively low power usage
- (-) must be physically at the location in order to record it
State: Wifi Near
Setup
Create a State context, click Wifi Near, fill in the SSID of an Access Point (AP)
with the best signal near where you want to identify.
About
Wifi Near does regular Wifi Scans and will activate when it recognizes an AP you have configured
is nearby. Note: you don't have to connect to the AP. You could configure e.g. the neighbours AP
if the signal is strong enough.
Check the Wifi Toggle box if you don't want wifi on all the time. It will then
be toggled when Tasker needs to do a scan.
Plus / Minus
- (+) very good accuracy and reliability
- (+) less power than GPS
- (+) works indoors too
- (-) need an AP nearby
Location: GPS
Setup
Create a location context, and deselect Net.
About
Frequency of GPS checks is controlled by Menu / Prefs / Monitor / GPS Check (screen on)
and Menu / Prefs / Monitor / Display Off All Checks. Higher frequencies mean
more battery usage but that location changes will be noticed more quickly.
When indoors, GPS will try a long time to get a signal, using a lot of battery. Adjust
it at Menu / Prefs / Monitor / GPS Timeout. Make the
timeout as low as you can until you start losing effectiveness.
More Info.
Plus / Minus
- (+) highly accurate in the open air
- (-) functions very poorly or not at all indoors. A bad side effect is that if you enter a building e.g. office while between the check times, it may never detect
your new location until you leave.
- (-) extreme power usage
- (-) needs network to get a first fix
Advanced Strategies
Multiple Contexts
Tasker does not check high-power contexts until all lower-power contexts in the same profile are active.
You can use this to reduce power consumption. For instance, if you use the Wifi Near state to
detect coming home, you could add a Location: Net context to the same profile, so that wifi scanning
will only take place when you are in the right neighbourhood.
Location Control
Disable GPS/Net location when they're not needed by creating a separate profile with e.g. a Time context which disables GPS during the night.
This works because Location contexts assume you are in the same location until there is a fix which says otherwise.
|