├── .editorconfig
├── .github
├── FUNDING.yml
└── workflows
│ └── npm.yml
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
└── src
└── index.d.ts
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 4
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 | end_of_line = lf
10 |
11 | [*.json]
12 | indent_size = 2
13 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | ko_fi: arnaught
2 |
--------------------------------------------------------------------------------
/.github/workflows/npm.yml:
--------------------------------------------------------------------------------
1 | name: Publish Package to npmjs
2 | on:
3 | release:
4 | types: [published]
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | permissions:
9 | contents: read
10 | id-token: write
11 | steps:
12 | - uses: actions/checkout@v4
13 | # Setup .npmrc file to publish to npm
14 | - uses: actions/setup-node@v4
15 | with:
16 | node-version: '20.x'
17 | registry-url: 'https://registry.npmjs.org'
18 | - run: npm ci
19 | - run: npm publish --provenance --access public
20 | env:
21 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22 |
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | *.swo
3 | node_modules/
4 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | examples/
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Rayquaza01
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # tasker-types
2 | Typescript definitions for Tasker functions
3 |
4 | Provides type definitions for [Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm)'s built in JavaScript(let) functions to help with developing Tasker JavaScript(lets) when using TypeScript and VSCode (or other TS Language Server).
5 |
6 | Based on the [Tasker Userguide](https://tasker.joaoapps.com/userguide/en/javascript.html)
7 |
8 | # Getting Started
9 | Add tasker-types to your project using:
10 | ```
11 | npm i --save-dev tasker-types
12 | ```
13 |
14 | Example:
15 | ```js
16 | // include types without importing module
17 | ///
18 |
19 | // alternatively
20 | // import type {} from "tasker-types";
21 |
22 | // Helpful JSDoc comments provided in intellisense
23 | mediaVol(5, true, true);
24 |
25 | flashLong(Math.floor(Math.random() * 100).toString());
26 |
27 | // Valid - autocomplete via intellisense
28 | audioRecord("/my/path/to/file.3gpp", "mic", "aac", "3gpp");
29 |
30 | // Invalid - throws error if ts checking enabled
31 | audioRecord("/my/path/to/file.3gpp", "mic", "aac", "mp3");
32 | // Error: Argument of type '"mp3"' is not assignable to parameter of type 'tkAudioRecordFormat'
33 |
34 | // you can also use functions via the tk interface
35 | tk.browseURL("https://google.com");
36 |
37 | exit();
38 | ```
39 |
40 | `mediaVol(5, true, true)` sets the media volume to 5, displays the new volume on screen and plays a sound.\
41 | `flashLong(Math.floor(Math.random() * 100).toString())` flashes a random number on the screen.\
42 | `audioRecord("/my/path/to/file.3gpp", "mic", "aac", "3gpp")` records from mic, using codec aac, in format 3gpp.\
43 | `tk.browseURL("https://google.com")` launches Google in your default browser.\
44 | `exit()` ends the JS and continues to the next action in the task.
45 |
46 | # Importing Types
47 |
48 | To include a type in a script, you can use either a [triple slash directive](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) or a [Type-only import](https://www.typescriptlang.org/docs/handbook/modules/reference.html#type-only-imports-and-exports)
49 |
50 | ## Triple Slash Directive
51 |
52 | This will import the type definitions, but won't actually *import* the module. Since nothing is actually being imported, the script will not be treated as a module, allowing the output from `tsc` to be used directly in Tasker. (Provided you don't have any other imports)
53 |
54 | ```js
55 | ///
56 | ```
57 |
58 | ## Type-only import
59 |
60 | This will import the type definitions, but won't actually import the module. Unlike the triple slash directive, the script will still be treated as a module. The output from `tsc` can't be used directly in Tasker without modification. However, it will work if you're using a bundler (such as `webpack`).
61 |
62 | ```js
63 | import type {} from "tasker-types";
64 | ```
65 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tasker-types",
3 | "version": "2.0.0",
4 | "lockfileVersion": 3,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "tasker-types",
9 | "version": "2.0.0",
10 | "license": "MIT"
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tasker-types",
3 | "version": "2.0.0",
4 | "description": "Typescript definitions for Tasker functions",
5 | "main": "",
6 | "types": "src/index.d.ts",
7 | "scripts": {},
8 | "keywords": [
9 | "tasker",
10 | "typescript",
11 | "types"
12 | ],
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/Rayquaza01/tasker-types"
16 | },
17 | "bugs": {
18 | "url": "https://github.com/Rayquaza01/tasker-types#issues"
19 | },
20 | "homepage": "https://github.com/Rayquaza01/tasker-types",
21 | "author": "Rayquaza01",
22 | "license": "MIT"
23 | }
24 |
--------------------------------------------------------------------------------
/src/index.d.ts:
--------------------------------------------------------------------------------
1 | // Type Definitions for Tasker Javascipt(let)
2 | // https://tasker.joaoapps.com/userguide/en/javascript.html
3 |
4 | // Types for parameters that only accept certain constants
5 | export type tkAudioStream = "call" | "system" | "ringer" | "media" | "alarm" | "notification";
6 | export type tkAudioRecordSource = "def" | "mic" | "call" | "callout" | "callin";
7 | export type tkAudioRecordCodec = "amrn" | "amrw" | "aac";
8 | export type tkAudioRecordFormat = "mp4" | "3gpp" | "amrn" | "amrw";
9 | export type tkButtonNames = "back" | "call" | "camera" | "endcall" | "menu" | "volup" | "voldown" | "search";
10 | export type tkConversionType = "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";
11 | export type tkDirection = "up" | "down" | "left" | "right" | "press";
12 | export type tkOrientation = "port" | "land";
13 | export type tkTextReplace = "repl" | "start" | "end";
14 | export type tkColourFilter = "bw" | "eblue" | "egreen" | "ered" | "grey" | "alpha";
15 | export type tkLocationMode = "gps" | "net" | "any";
16 | export type tkLanguageModel = "web" | "free";
17 | export type tkMediaAction = "next" | "pause" | "prev" | "toggle" | "stop" | "play";
18 | export type tkRebootMode = "normal" | "recovery" | "bootloader";
19 | export type tkRotationDirection = "left" | "right";
20 | export type tkRotationDegrees = 45 | 90 | 135 | 180;
21 | export type tkIntentAction = "receiver" | "activity" | "service";
22 | export type tkIntentCategory = "none" | "alt" | "browsable" | "cardock" | "home" | "info" | "launcher" | "perference" | "selectedalt" | "tab" | "test";
23 | export type tkSettingsScreen = "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" | "wireless";
24 | export type tkDisplayAs = "Overlay" | "OverBlocking" | "OverBlockFullDisplay" | "Dialog" | "DialogBlur" | "DialogDim" | "ActivityFullWindow" | "ActivityFullDisplay" | "ActivityFullDisplayNoTitle";
25 | export type tkSilentMode = "off" | "vibrate" | "on";
26 | export type tkStayOnMode = "never" | "ac" | "usb" | "any";
27 | export type tkCamera = 0 | 1;
28 |
29 | // We are using global declarations, because tasker function are not imported, and called without defining them
30 | interface TK {
31 | /**
32 | * Set alarm volume
33 | * @param level Set the relevant system volume to *level*. (0-7)
34 | * @param display If *display* is true, the new level will be flashed up on-screen.
35 | * @param sound If *sound* is true, a tone will sound at the new level.
36 | */
37 | alarmVol(level: number, display: boolean, sound: boolean): boolean
38 |
39 | /**
40 | * Set bluetooth voice volume
41 | * @param level Set the relevant system volume to *level*.
42 | * @param display If *display* is true, the new level will be flashed up on-screen.
43 | * @param sound If *sound* is true, a tone will sound at the new level.
44 | */
45 | btVoiceVol(level: number, display: boolean, sound: boolean): boolean
46 |
47 | /**
48 | * Set call volume
49 | * @param level Set the relevant system volume to *level*.
50 | * @param display If *display* is true, the new level will be flashed up on-screen.
51 | * @param sound If *sound* is true, a tone will sound at the new level.
52 | */
53 | callVol(level: number, display: boolean, sound: boolean): boolean
54 |
55 | /**
56 | * Set dtmf volume
57 | * @param level Set the relevant system volume to *level*.
58 | * @param display If *display* is true, the new level will be flashed up on-screen.
59 | * @param sound If *sound* is true, a tone will sound at the new level.
60 | */
61 | dtmfVol(level: number, display: boolean, sound: boolean): boolean
62 |
63 | /**
64 | * Set media volume
65 | * @param level Set the relevant system volume to *level*. (0-15)
66 | * @param display If *display* is true, the new level will be flashed up on-screen.
67 | * @param sound If *sound* is true, a tone will sound at the new level.
68 | */
69 | mediaVol(level: number, display: boolean, sound: boolean): boolean
70 |
71 | /**
72 | * Set notification volume
73 | * @param level Set the relevant system volume to *level*.
74 | * @param display If *display* is true, the new level will be flashed up on-screen.
75 | * @param sound If *sound* is true, a tone will sound at the new level.
76 | */
77 | notificationVol(level: number, display: boolean, sound: boolean): boolean
78 |
79 | /**
80 | * Set system volume
81 | * @param level Set the relevant system volume to *level*.
82 | * @param display If *display* is true, the new level will be flashed up on-screen.
83 | * @param sound If *sound* is true, a tone will sound at the new level.
84 | */
85 | systemVol(level: number, display: boolean, sound: boolean): boolean
86 |
87 | /**
88 | * Set ringer volume
89 | * @param level Set the relevant system volume to *level*. (0-7)
90 | * @param display If *display* is true, the new level will be flashed up on-screen.
91 | * @param sound If *sound* is true, a tone will sound at the new level.
92 | */
93 | ringerVol(level: number, display: boolean, sound: boolean): boolean
94 |
95 | /**
96 | * Records audio
97 | *
98 | * The JavaScript does **not** wait for the audio recording to complete.
99 | *
100 | * See also: {@link audioRecordStop}().
101 | * @param destPath where to put the recording. Note that a file extension is
102 | * not necessary, it will correspond to the selected *format*.
103 | * @param source one of **def**, **mic**, **call**, **callout** or **callin**
104 | * @param codec one of **amrn**, **amrw** or **aac**
105 | * @param format one of **mp4**, **3gpp**, **amrn** or **amrw**
106 | */
107 | audioRecord(destPath: string, source: tkAudioRecordSource, codec: tkAudioRecordCodec, format: tkAudioRecordFormat): boolean
108 |
109 | /**
110 | * Stop recording previously initiated by {@link audioRecord}().
111 | */
112 | audioRecordStop(): boolean
113 |
114 | /**
115 | * Open the default browser at the specifed URL.
116 | * @param url URL to open
117 | */
118 | browseURL(url: string): boolean
119 |
120 | /**
121 | * Simulate a press of the named button.
122 | *
123 | * This function requires a rooted device.
124 | * @param name must be one of **back**, **call**, **camera**, **endcall**,
125 | * **menu**, **volup**, **voldown** or **search**.
126 | */
127 | button(name: tkButtonNames): boolean
128 |
129 | /**
130 | * Make a phone call
131 | * @param num The phone number to call
132 | * @param autodial If *autoDial* is **false**, the phone app will be brought
133 | * up with the number pre-inserted, if **true** the number will also be dialed.
134 | */
135 | call(num: string, autodial: boolean): boolean
136 |
137 | /**
138 | * Block **outgoing** calls
139 | * [matching](https://tasker.joaoapps.com/userguide/en/matching.html) *numMatch*.
140 | * @param numMatch Pattern to block
141 | * @param showInfo If showInfo is set, Tasker will flash a message when a call is blocked.
142 | */
143 | callBlock(numMatch: string, showInfo: boolean): boolean
144 |
145 | /**
146 | * Divert **outgoing** calls
147 | * [matching](https://tasker.joaoapps.com/userguide/en/matching.html)
148 | * *fromMatch* to the number *to*.
149 | * @param fromMatch Pattern to match outgoing calls
150 | * @param to Number to divert to
151 | * @param showInfo If *showInfo* is set, Tasker will flash a message when a call is diverted.
152 | */
153 | callDivert(fromMatch: string, to: string, showInfo: boolean): boolean
154 |
155 | /**
156 | * Stop blocking or diverting outgoing calls previously specified with
157 | * callBlock or callDivert.
158 | * @param numMatch Pattern to stop blocking/diverting
159 | */
160 | callRevert(numMatch: string): boolean
161 |
162 | /**
163 | * Turn on or off Android Car Mode.
164 | * @param onFlag On or off
165 | */
166 | carMode(onFlag: boolean): boolean
167 |
168 | /**
169 | * Clear the passphrase for the specified *keyName*.
170 | *
171 | * See Also: [Encryption](https://tasker.joaoapps.com/userguide/en/encryption.html)
172 | * in the Userguide.
173 | * @param keyName key to clear
174 | */
175 | clearKey(keyName: string): boolean
176 |
177 | /**
178 | * Show an email composition dialog with any specified fields pre-filled.
179 | *
180 | * The JavaScript does **not** wait for the email to be sent before continuing.
181 | * @param to To field
182 | * @param subject Subject field
183 | * @param message Message body
184 | */
185 | composeEmail(to: string, subject: string, message: string): boolean
186 |
187 | /**
188 | * Show an MMS composition dialog with any specified fields pre-filled.
189 | *
190 | * The JavaScript does **not** wait for the MMS to be sent before continuing.
191 | * @param to MMS To Field
192 | * @param subject MMS Subject Field
193 | * @param message MMS Body
194 | * @param attachmentPath Path to attachment
195 | */
196 | composeMMS(to: string, subject: string, message: string, attachmentPath: string): boolean
197 |
198 | /**
199 | * Show an SMS composition dialog with any specified fields pre-filled.
200 | *
201 | * The JavaScript does **not** wait for the SMS to be sent before continuing.
202 | * @param to SMS To Field
203 | * @param message SMS Body
204 | */
205 | composeSMS(to: string, message: string): boolean
206 |
207 | /**
208 | * Convert from one type of value to another.
209 | *
210 | * See also: action [Variable Convert](https://tasker.joaoapps.com/userguide/en/help/ah_convert_variable.html).
211 | * @param val Value to convert
212 | * @param conversionType must be one of the string constants: **byteToKbyte**,
213 | * **byteToMbyte**, **byteToGbyte**, **datetimeToSec**, **secToDatetime**,
214 | * **secToDatetimeM**, **secToDatetimeL**, **htmlToText**, **celsToFahr**,
215 | * **fahrToCels**, **inchToCent**, **metreToFeet**, **feetToMetre**, **kgToPound**,
216 | * **poundToKg**, **kmToMile**, **mileToKm**, **urlDecode**, **urlEncode**,
217 | * **binToDec**, **decToBin**, **hexToDec**, **decToHex**, **base64encode**,
218 | * **base64decode**, **toMd5**, **toSha1**, **toLowerCase**, **toUpperCase**,
219 | * **toUpperCaseFirst**.
220 | */
221 | convert(val: string, conversionType: tkConversionType): string
222 |
223 | /**
224 | * Create a directory
225 | * @param dirPath Create the named *dirPath*.
226 | * @param createParent If *createParent* is specified and any parent
227 | * directory does not exist, it will also be created.
228 | * @param useRoot If *useRoot* is specified, the operation will be performed
229 | * as the root user (where available).
230 | */
231 | createDir(dirPath: string, createParent: boolean, useRoot: boolean): boolean
232 |
233 | /**
234 | * Create the named [scene](https://tasker.joaoapps.com/userguide/en/scenes.html)
235 | * without displaying it.
236 | * @param sceneName Scene to create
237 | */
238 | createScene(sceneName: string): boolean
239 |
240 | /**
241 | * Crop an image in Tasker's image buffer previously loaded via loadImage.
242 | * @param fromLeftPercent Percentage from left to crop
243 | * @param fromRightPercent Percentage from right to crop
244 | * @param fromTopPercent Percentage from top to crop
245 | * @param fromBottomPercent Percentage from bottom to crop
246 | */
247 | cropImage(fromLeftPercent: number, fromRightPercent: number, fromTopPercent: number, fromBottomPercent: number): boolean
248 |
249 | /**
250 | * As decryptFile(), but decrypts each file in the specified directory in turn.
251 | *
252 | * See Also: [Encryption](https://tasker.joaoapps.com/userguide/en/encryption.html)
253 | * in the Userguide,
254 | * [Decrypt File](https://tasker.joaoapps.com/userguide/en/help/ah_decrypt_file.html)
255 | * action.
256 | * @param path Directory to decrypt
257 | * @param key Encryption key
258 | * @param removeKey If *removeKey* is not set, the entered passphrase will
259 | * be reapplied automatically to the next encryption/decryption operation with
260 | * the specified *keyName*.
261 | */
262 | decryptDir(path: string, key: string, removeKey: boolean): boolean
263 |
264 | /**
265 | * Decrypt the specified file using the encryption parameters specified in
266 | * `Menu / Prefs / Action`.
267 | *
268 | * See Also: [Encryption](https://tasker.joaoapps.com/userguide/en/encryption.html)
269 | * in the Userguide,
270 | * [Decrypt File](https://tasker.joaoapps.com/userguide/en/help/ah_decrypt_file.html)
271 | * action.
272 | * @param path Path of file
273 | * @param key Encryption key
274 | * @param removeKey If *removeKey* is not set, the entered passphrase will
275 | * be reapplied automatically to the next encryption/decryption operation
276 | * with the specified *keyName*.
277 | */
278 | decryptFile(path: string, key: string, removeKey: boolean): boolean
279 |
280 | /**
281 | * Delete a directory
282 | * @param dirPath Path of directory to delete
283 | * @param recurse Delete recursively (if *dirPath* is not empty)
284 | * @param useRoot If *useRoot* is specified, the operation will be performed
285 | * as the root user (where available).
286 | */
287 | deleteDir(dirPath: string, recurse: boolean, useRoot: boolean): boolean
288 |
289 | /**
290 | * Delete a file
291 | *
292 | * See also: action [Delete File](https://tasker.joaoapps.com/userguide/en/help/ah_delete_file.html)
293 | * @param filePath Path of file to delete
294 | * @param shredTimes Range 0-10
295 | * @param useRoot If *useRoot* is specified, the operation will be performed
296 | * as the root user (where available).
297 | */
298 | deleteFile(filePath: string, shredTimes: number, useRoot: boolean): boolean
299 |
300 | /**
301 | * Hide the named [scene](https://tasker.joaoapps.com/userguide/en/scenes.html)
302 | * if it's visible, then destroy it.
303 | * @param sceneName Scene name
304 | */
305 | destroyScene(sceneName: string): boolean
306 |
307 | /**
308 | * Whether the display brightness should automatically adjust to the ambient
309 | * light or not.
310 | * @param onFlag On or off
311 | */
312 | displayAutoBright(onFlag: boolean): boolean
313 |
314 | /**
315 | * Whether the display orientation should change based on the physical
316 | * orientation of the device.
317 | * @param onFlag On or off
318 | */
319 | displayAutoRotate(onFlag: boolean): boolean
320 |
321 | /**
322 | * How long the period of no-activity should be before the display is turned off.
323 | * @param hours Hours of inactivity
324 | * @param minutes Minutes of inactivity
325 | * @param seconds Seconds of inactivity
326 | */
327 | displayTimeout(hours: number, minutes: number, seconds: number): boolean
328 |
329 | /**
330 | * Simulate a movement or press of the hardware dpad (or trackball).
331 | *
332 | * This function requires a rooted device.
333 | * @param direction must be one of **up**, **down**, **left**, **right** or **press**.
334 | * @param noRepeats
335 | */
336 | dpad(direction: tkDirection, noRepeats: number): boolean
337 |
338 | /**
339 | * Enable or disable the named Tasker profile.
340 | * @param name Profile name
341 | * @param enable Enable or disable
342 | */
343 | enableProfile(name: string, enable: boolean): boolean
344 |
345 | /**
346 | * As encryptFile(), but encrypts each file in the specified directory in turn.
347 | *
348 | * See Also: [Encryption](https://tasker.joaoapps.com/userguide/en/encryption.html)
349 | * in the Userguide, [Encrypt File](https://tasker.joaoapps.com/userguide/en/help/ah_encrypt_file.html)
350 | * action.
351 | * @param path Path to encrypt
352 | * @param keyName Encryption key
353 | * @param rememberKey If *rememberKey* is set, the entered passphrase will
354 | * be reapplied automatically to the next encryption/decryption operation
355 | * with the specified *keyName*.
356 | * @param shredOriginal If *shredOriginal* is specified, the original
357 | * file will be overwritten several times with random bits if encryption is successful.
358 | */
359 | encryptDir(path: string, keyName: string, rememberKey: string, shredOriginal: boolean): boolean
360 |
361 | /**
362 | * Set the background [colour](https://tasker.joaoapps.com/userguide/en/javascript.html#colour)
363 | * of the specified [scene](https://tasker.joaoapps.com/userguide/en/scenes.html)
364 | * element.
365 | *
366 | * See also: action [Element Back Colour](https://tasker.joaoapps.com/userguide/en/help/ah_scene_element_background_colour.html).
367 | * @param scene Scene name
368 | * @param element Element name
369 | * @param startColour Background colour
370 | * @param endColour End Colour is only relevant if the element's background
371 | * has a Shader specified.
372 | */
373 | elemBackColour(scene: string, element: string, startColour: string, endColour: string): boolean
374 |
375 | /**
376 | * Set the border [colour](https://tasker.joaoapps.com/userguide/en/javascript.html#colour)
377 | * and width of the specified [scene](https://tasker.joaoapps.com/userguide/en/scenes.html) element.
378 | * @param scene Scene name
379 | * @param element Element name
380 | * @param width Border width
381 | * @param colour Border colour
382 | */
383 | elemBorder(scene: string, element: string, width: number, colour: string): boolean
384 |
385 | /**
386 | * Move an element within it's scene.
387 | *
388 | * See also: action [Element Position](https://tasker.joaoapps.com/userguide/en/help/ah_scene_element_position.html).
389 | * @param scene Scene name
390 | * @param element Element name
391 | * @param orientation Must be one of **port** or **land**
392 | * @param x X position
393 | * @param y Y position
394 | * @param animMS indicates the duration of the corresponding animation in MS.
395 | * A zero-value indicates no animation.
396 | */
397 | elemPosition(scene: string, element: string, orientation: tkOrientation, x: number, y: number, animMS: number): boolean
398 |
399 | /**
400 | * Set the text of the specified [scene](https://tasker.joaoapps.com/userguide/en/scenes.html) element.
401 | *
402 | * See also: action [Element Text](https://tasker.joaoapps.com/userguide/en/help/ah_scene_element_text.html).
403 | * @param scene Scene name
404 | * @param element Element name
405 | * @param position must be one of **repl** (replace existing text
406 | * completely), **start** (insert before existing text) or **end**
407 | * (append after existing text).
408 | * @param text Text to set
409 | */
410 | elemText(scene: string, element: string, position: tkTextReplace, text: string): boolean
411 |
412 | /**
413 | * Set the text [colour](https://tasker.joaoapps.com/userguide/en/javascript.html#colour)
414 | * of the specified [scene](https://tasker.joaoapps.com/userguide/en/scenes.html) element.
415 | *
416 | * See also: action [Element Text Colour](https://tasker.joaoapps.com/userguide/en/help/ah_scene_element_text_colour.html).
417 | * @param scene Scene name
418 | * @param element Element name
419 | * @param colour Text colour
420 | */
421 | elemTextColour(scene: string, element: string, colour: string): boolean
422 |
423 | /**
424 | * Set the text size of the specified [scene](https://tasker.joaoapps.com/userguide/en/scenes.html) element.
425 | *
426 | * See also: action [Element Text Size](https://tasker.joaoapps.com/userguide/en/help/scene_element_text_size.html).
427 | * @param scene Scene name
428 | * @param element Element name
429 | * @param size Text size
430 | */
431 | elemTextSize(scene: string, element: string, size: number): boolean
432 |
433 | /**
434 | * Make the specified [scene](https://tasker.joaoapps.com/userguide/en/scenes.html) element
435 | * visible or invisible.
436 | *
437 | * See also: action [Element Visibility](https://tasker.joaoapps.com/userguide/en/help/ah_scene_element_visibility.html).
438 | * @param scene Scene name
439 | * @param element Element name
440 | * @param visible Show or hide
441 | * @param animationTimeMS Animation length (ms)
442 | */
443 | elemVisibility(scene: string, element: string, visible: boolean, animationTimeMS: number): boolean
444 |
445 | /**
446 | * Terminate the current call (if there is one).
447 | */
448 | endCall(): boolean
449 |
450 | /**
451 | * Encrypt the specified file using the encryption parameters specified in `Menu / Prefs / Action`.
452 | *
453 | * See Also: [Encryption](https://tasker.joaoapps.com/userguide/en/encryption.html)
454 | * in the Userguide, [Encrypt File](https://tasker.joaoapps.com/userguide/en/help/ah_encrypt_file.html)
455 | * action.
456 | * @param path File to encrypt
457 | * @param keyName Encryption key
458 | * @param rememberKey If *rememberKey* is set, the entered passphrase will be
459 | * reapplied automatically to the next encryption/decryption operation with
460 | * the specified *keyName*.
461 | * @param shredOriginal If *shredOriginal* is specified, the original file
462 | * will be overwritten several times with random bits if encryption is
463 | * successful.
464 | */
465 | encryptFile(path: string, keyName: string, rememberKey: string, shredOriginal: boolean): boolean
466 |
467 | /**
468 | * Show a dialog to enter the passphrase for the specified *keyName*.
469 | *
470 | * The JavaScript waits until the dialog has been dismissed or *timeoutSecs* reached.
471 | * @param title Title
472 | * @param keyName Name of key
473 | * @param showOverKeyguard Show scene over keyguard
474 | * @param confirm if set, the passphrase must be entered twice to ensure it is correct.
475 | * @param background [optional] a file path or file URI to a background image.
476 | * @param layout the name of a user-created [scene](https://tasker.joaoapps.com/userguide/en/scenes.html)
477 | * to use in place of the built-in scene.
478 | * @param timeoutSecs Time (seconds) to wait before ending
479 | */
480 | enterKey(
481 | title: string,
482 | keyName: string,
483 | showOverKeyguard: boolean,
484 | confirm: boolean,
485 | background: string,
486 | layout: string,
487 | timeoutSecs: number
488 | ): boolean
489 |
490 |
491 | /**
492 | * Filter an image previously loaded into Tasker's image buffer via loadImage()
493 | * @param mode Possible values of *mode* are:
494 | * * **bw**: convert to black & white, using *value* as a threshold
495 | * * **eblue**: enhance blue values by *value*
496 | * * **egreen**: enhance green values by *value*
497 | * * **ered**: enhance red values by *value*
498 | * * **grey**: convert to greyscale, *value* is unused
499 | * * **alpha**: set pixel alpha (opposite of transparency) to *value*
500 | * @param value should be 1-254
501 | */
502 | filterImage(mode: tkColourFilter, value: number): boolean
503 |
504 | /**
505 | * Flip an image previously loaded into Tasker's image buffer via loadImage()
506 | * @param horizontal If *horizontal* is false, the image is flipped vertically.
507 | */
508 | flipImage(horizontal: boolean): boolean
509 |
510 | /**
511 | * Stop execution of the JavaScript.
512 | */
513 | exit(): void
514 |
515 | /**
516 | * Flash a short-duration Android 'Toast' message.
517 | * @param message Message to display in toast
518 | */
519 | flash(message: string): void
520 |
521 | /**
522 | * Flash a long-duration Android 'Toast' message.
523 | * @param message Message to display in toast
524 | */
525 | flashLong(message: string): void
526 |
527 | /**
528 | * Try to get a fix of the current device location.
529 | *
530 | * Fix coordinates are stored in the global Tasker variables %**LOC** (GPS)
531 | * and/or %**LOCN** (Net). The value can be retrieved with the global
532 | * function. Several other parameters of the fix are also available,
533 | * see [Variables](https://tasker.joaoapps.com/userguide/en/variables.html).
534 | *
535 | * Example:
536 | *
537 | * ```js
538 | * var lastFix = global( 'LOC' );
539 | * if (
540 | * getLocation( 'gps' ) &&
541 | * ( global( 'LOC' ) != lastFix )
542 | * ) {
543 | * flash( "New fix: " + global( 'LOC' ) );
544 | * }
545 | * ```
546 | *
547 | * See also: action [Get Location](https://tasker.joaoapps.com/userguide/en/help/ah_get_fix.html),
548 | * function stopLocation.
549 | * @param source must be one of **gps**, **net** or **any**.
550 | * @param keepTracking If *keepTracking* is set, the specified source(s)
551 | * will be left tracking with the purpose of providing a much quicker fix
552 | * next time the function is called.
553 | * @param timeoutSecs Timeout (seconds) for action
554 | */
555 | getLocation(source: tkLocationMode, keepTracking: boolean, timeoutSecs: number): boolean
556 |
557 |
558 | /**
559 | * Get voice input and convert to text.
560 | * @param prompt Label for the dialog that is shown during voice acquisition.
561 | * @param languageModel gives the speech recognition engine a clue as to the
562 | * context of the speech. It must be one of **web** for 'web search' or
563 | * **free** for 'free-form'.
564 | * @param timeout Timeout for action
565 | */
566 | getVoice(prompt: string, languageModel: tkLanguageModel, timeout: number): string
567 |
568 | /**
569 | * Retrieve the value of a Tasker global variable. Prefixing the name with % is optional.
570 | * @param varName Global variable name
571 | */
572 | global(varName: string): string
573 |
574 | /**
575 | * Go to the Android home screen. *screenNum* is not supported by all home screens.
576 | * @param screenNum Home screen page to go to
577 | */
578 | goHome(screenNum: number): void
579 |
580 | /**
581 | * Enable/disable system setting Haptic Feedback.
582 | * @param onFlag Should haptics be enabled or disabled
583 | */
584 | haptics(onFlag: boolean): boolean
585 |
586 | /**
587 | * Hide the named scene if it's visible.
588 | * @param sceneName The name of the scene to hide
589 | */
590 | hideScene(sceneName: string): boolean
591 |
592 | /**
593 | * List all files in the specified *dirPath*.
594 | *
595 | * Returns a newline-separated list of subfiles.
596 | * If no files or found or an error occurs, the returned value will be undefined.
597 | * @param dirPath Directory to list files
598 | * @param hiddenToo If **hiddenToo** is specified, files starting with
599 | * period are included, otherwise they are not.
600 | */
601 | listFiles(dirPath: string, hiddenToo: boolean): string | undefined
602 |
603 | /**
604 | * Start up the named app.
605 | * @param name can be a package name or app label, it's tested first against
606 | * known package names. Note: app label could be localized to another
607 | * language if the script is used in an exported app.
608 | * @param data is in URI format and app-specific.
609 | * @param excludeFromRecents When *excludeFromRecents* is true, the app
610 | * will not appear in the home screen 'recent applications' list.
611 | */
612 | loadApp(name: string, data: string, excludeFromRecents: boolean): boolean
613 |
614 | /**
615 | * Load an image into Tasker's internal image buffer.
616 | *
617 | * See also [Load Image](https://tasker.joaoapps.com/userguide/en/help/ah_load_image.html) action.
618 | * @param uri Must start with `file://` followed by a local path
619 | */
620 | loadImage(uri: string): boolean
621 |
622 | /**
623 | * Show a lock screen, preventing user interaction with the covered part of
624 | * the screen. The JavaScript waits until the code has been entered or the
625 | * lock cancelled (see below).
626 | * @param title Lock screen title
627 | * @param code the numeric code which must be entered for unlock
628 | * @param allowCancel show a button to remove the lockscreen, which causes a
629 | * return to the Android home screen
630 | * @param rememberCode the code will be remembered and automatically entered
631 | * when the lock screen is show in future, until the display next turns off
632 | * @param fullScreen Make lockscreen fullscreen
633 | * @param background [optional] a file path or file URI to a background image.
634 | * @param layout the name of a user-created [scene](https://tasker.joaoapps.com/userguide/en/scenes.html)
635 | * to use in place of the built-in lock scene
636 | */
637 | lock(
638 | title: string,
639 | code: string,
640 | allowCancel: boolean,
641 | rememberCode: boolean,
642 | fullScreen: boolean,
643 | background: string,
644 | layout: string
645 | ): boolean
646 |
647 | /**
648 | * Retrieve the value of a Tasker scene-local variable. The name should not
649 | * be prefixed with %.
650 | *
651 | * This function is only for use by JavaScript embedded in HTML and accessed
652 | * via a WebView scene element.
653 | * @param varName
654 | */
655 | local(varName: string): string
656 |
657 | /**
658 | * Control media via simulation of hardware buttons.
659 | * @param action Possible *actions* are **next**, **pause**, **prev**,
660 | * **toggle**, **stop** or **play**.
661 | */
662 | mediaControl(action: tkMediaAction): boolean
663 |
664 | /**
665 | * Mute or unmute the device's microphone (if present),
666 | * @param shouldMute Should the microphone be muted
667 | */
668 | micMute(shouldMute: boolean): boolean
669 |
670 | /**
671 | * Enable or disable the system Mobile Data setting.
672 | *
673 | * See also: action [Mobile Data](https://tasker.joaoapps.com/userguide/en/help/ah_mobile_data_direct.html)
674 | * @param set Enable or disable
675 | */
676 | mobileData(set: boolean): boolean
677 |
678 | /**
679 | * Skip back by *seconds* during playback of a music file previously started
680 | * by musicPlay.
681 | *
682 | * See also: {@link musicSkip}, {@link musicStop}
683 | * @param seconds Seconds to skip back
684 | */
685 | musicBack(seconds: number): boolean
686 |
687 | /**
688 | * Play a music file via Tasker's internal music player.
689 | *
690 | * This function does **not** not wait for completion.
691 | *
692 | * The last 3 arguments may be ommitted, in which case they default to **0**,
693 | * **false** and **media** respectively.
694 | *
695 | * See also: {@link musicStop}, {@link musicBack}, {@link musicSkip}
696 | * @param path Path to music file
697 | * @param offsetSecs Seconds from beginning of file
698 | * @param loop Should audio loop
699 | * @param stream which [audio stream](https://tasker.joaoapps.com/userguide/en/javascript.html#streams)
700 | * the music should be played
701 | */
702 | musicPlay(path: string, offsetSecs?: number, loop?: boolean, stream?: tkAudioStream): boolean
703 |
704 | /**
705 | * Skip forwards by seconds during playback of a music file previously
706 | * started by musicPlay.
707 | *
708 | * See also: {@link musicBack}, {@link musicStop}
709 | * @param seconds Seconds to skip forward
710 | */
711 | musicSkip(seconds: number): boolean
712 |
713 | /**
714 | * Stop playback of a music file previously started by musicPlay.
715 | *
716 | * See also: {@link musicBack}, {@link musicSkip}
717 | */
718 | musicStop(): boolean
719 |
720 | /**
721 | * Turn on or off Android Night Mode.
722 | * @param onFlag On or off
723 | */
724 | nightMode(onFlag: boolean): boolean
725 |
726 | /**
727 | * Show a popup dialog. The JavaScript waits until the popup has been
728 | * dismissed or the timeout reached.
729 | * @param title Popup title
730 | * @param text Popup text
731 | * @param showOverKeyguard Show scene over keyguard
732 | * @param background [optional] a file path or file URI to a background image.
733 | * @param layout the name of a user-created [scene](https://tasker.joaoapps.com/userguide/en/scenes.html)
734 | * to use in place of the built-in popup scene.
735 | * @param timeoutSecs Time (seconds) to wait before ending
736 | */
737 | popup(
738 | title: string,
739 | text: string,
740 | showOverKeyguard: boolean,
741 | background: string,
742 | layout: string,
743 | timeoutSecs: number
744 | ): boolean
745 |
746 | /**
747 | * Run the Tasker task *taskName*.
748 | *
749 | * Note that the JavaScript does not wait for the task to complete.
750 | * @param taskName Task name
751 | * @param priority Priority
752 | * @param parameterOne Parameter for task
753 | * @param parameterTwo Parameter for task
754 | */
755 | performTask(taskName: string, priority: number, parameterOne: string, parameterTwo: string): boolean
756 |
757 | /**
758 | * Whether the named Tasker profile is currently active.
759 | *
760 | * Returns false if the profile name is unknown.
761 | * @param profileName Profile name
762 | */
763 | profileActive(profileName: string): boolean
764 |
765 | /**
766 | * Enable or disable the Android Notification Pulse system setting.
767 | * @param onFlag Enable or disable
768 | */
769 | pulse(onFlag: boolean): boolean
770 |
771 | /**
772 | * Read the contents of a text file.
773 | * @param path File to read
774 | */
775 | readFile(path: string): string
776 |
777 | /**
778 | * Reboot the device.
779 | *
780 | * Requires a rooted device.
781 | *
782 | * See also: function {@link shutdown}
783 | * @param type one of **normal**, **recovery** or **bootloader**.
784 | * It can be ommitted and defaults to **normal**.
785 | */
786 | reboot(type?: tkRebootMode): boolean
787 |
788 | /**
789 | * Scale the current image in Tasker's image buffer to the specified dimensions.
790 | * @param width Width of image
791 | * @param height Height of image
792 | */
793 | resizeImage(width: number, height: number): boolean
794 |
795 | /**
796 | * Rotate the current image in Tasker's image buffer.
797 | * @param dir must be one of **left** or **right**.
798 | * @param degrees must be one of **45**, **90**, **135** or **180**.
799 | */
800 | rotateImage(dir: tkRotationDirection, degrees: tkRotationDegrees): boolean
801 |
802 | /**
803 | * Save the current image in Tasker's image buffer to the specified file path.
804 | *
805 | * [Save Image](https://tasker.joaoapps.com/userguide/en/help/ah_save_image.html) action.
806 | * @param path
807 | * @param qualityPercent
808 | * @param deleteFromMemoryAfter
809 | */
810 | saveImage(path: string, qualityPercent: number, deleteFromMemoryAfter: boolean): boolean
811 |
812 | /**
813 | * Cause the device to say *text* out loud.
814 | *
815 | * The script waits for the speech to be finished.
816 | * @param text Text to say
817 | * @param enginge the speech engine e.g. **com.svox.classic** Defaults to the
818 | * system default (specify undefined for that)
819 | * @param voice the voice to use (must be supported by *engine*).
820 | * Defaults to the current system language (specify undefined for that)
821 | * @param stream to which [audio stream](https://tasker.joaoapps.com/userguide/en/javascript.html#streams)
822 | * the speech should be made
823 | * @param pitch 1-10
824 | * @param speed 1-10
825 | */
826 | say(
827 | text: string,
828 | enginge: string | undefined,
829 | voice: string | undefined,
830 | stream: tkAudioStream,
831 | pitch: number,
832 | speed: number
833 | ): boolean
834 |
835 | /**
836 | * Send an intent. Intents are Android's high-level application interaction system.
837 | *
838 | * Any parameter may be specified as undefined.
839 | *
840 | * See also: action [Send Intent](https://tasker.joaoapps.com/userguide/en/help/ah_send_intent.html).
841 | * @param action Intent action
842 | * @param targetComp the type of application component to target, one of
843 | * **receiver**, **activity** or **service**. Defaults to **receiver**.
844 | * @param package the application package to limt the intent to
845 | * @param className the application class to limit the intent to
846 | * @param category one of **none**, **alt**, **browsable**, **cardock**,
847 | * **deskdock**, **home**, **info**, **launcher**, **preference**,
848 | * **selectedalt**, **tab** or **test**, defaults to **none**
849 | * @param data Intent data
850 | * @param mimeType Intent mime type
851 | * @param extras extra data to pass, in the format key:value. May be undefined. Maximum length 2.
852 | */
853 | sendIntent(
854 | action: tkIntentAction,
855 | targetComp: string,
856 | package: string,
857 | className: string,
858 | category: tkIntentCategory,
859 | data: string,
860 | mimeType: string,
861 | extras: string[]
862 | ): boolean
863 |
864 | /**
865 | * Send an SMS.
866 | *
867 | * See also: action [Send SMS](https://tasker.joaoapps.com/userguide/en/help/ah_send_sms.html)
868 | * @param number Number to send message to
869 | * @param text SMS body
870 | * @param storeInMessagingApp Show text message in messaging app
871 | */
872 | sendSMS(number: string, text: string, storeInMessagingApp: boolean): boolean
873 |
874 | /**
875 | * Enable or disable Airplane Mode.
876 | *
877 | * Get the current value with:
878 | * ```js
879 | * var enabled = global( 'AIR' );
880 | * ```
881 | *
882 | * See also: function {@link setAirplaneRadios}
883 | * @param setOn On or off
884 | */
885 | setAirplaneMode(setOn: boolean): boolean
886 |
887 | /**
888 | * Specify the radios which will be **disabled** when the device enters Airplane Mode.
889 | *
890 | * Get the current value with:
891 | * ```js
892 | * var radios = global( 'AIRR' );
893 | * ```
894 | *
895 | * See also: function {@link setAirplaneMode}
896 | * @param disableRadios a comma-separated list with radio names from the
897 | * following set: **cell**, **nfc**, **wifi**, **wimax**, **bt**.
898 | */
899 | setAirplaneRadios(disableRadios: string): boolean
900 |
901 | /**
902 | * Create an alarm in the default alarm clock app.
903 | *
904 | * Requires Android version 2.3+.
905 | * @param hour Alarm time (hour)
906 | * @param min Alarm time (minute)
907 | * @param message Alarm message (optional)
908 | * @param confirmFlag specifies whether the app should confirm that the alarm has been set.
909 | */
910 | setAlarm(hour: number, min: number, message: string, confirmFlag: boolean): boolean
911 |
912 | /**
913 | * Enable or disable the global auto-sync setting.
914 | * @param setOn On or off
915 | */
916 | setAutoSync(setOn: boolean): boolean
917 |
918 | /**
919 | * Force the system to scan the external storage card for new/deleted media.
920 | *
921 | * See also: action [Scan Card](https://tasker.joaoapps.com/userguide/en/help/ah_scan_card.html)
922 | * @param path If *path* is defined, only that will be scanned.
923 | */
924 | scanCard(path?: string): boolean
925 |
926 | /**
927 | * Enable or disable the Bluetooth radio (if present).
928 | * Test BT state with:
929 | * ```js
930 | * if ( global( 'BLUE' ) == "on" ) { doSomething(); }
931 | * ```
932 | * @param setOn On or off
933 | */
934 | setBT(setOn: boolean): boolean
935 |
936 | /**
937 | * Set the bluetooth adapter ID (the name as seen by other devices).
938 | * @param toSet ID to set
939 | */
940 | setBTID(toSet: string): boolean
941 |
942 | /**
943 | * Set the value of a Tasker global user variable. Prefixing varName with % is optional.
944 | *
945 | * Arrays are **not** supported due to limitations of the Android JS interface.
946 | * @param varName Global variable name
947 | * @param newValue New value of variable
948 | */
949 | setGlobal(varName: string, newValue: string): void
950 |
951 | /**
952 | * Set the passphrase for the specified keyName.
953 | *
954 | * See Also: [Encryption](https://tasker.joaoapps.com/userguide/en/encryption.html)
955 | * in the Userguide.
956 | * @param keyName Key name to set
957 | * @param passphrase Passphrase for key
958 | */
959 | setKey(keyName: string, passphrase: string): boolean
960 |
961 | /**
962 | * Set the value of a Tasker **scene-local** user variable. Variable names
963 | * should not be prefixed with %.
964 | *
965 | * This function is only for use by JavaScript embedded in HTML and accessed
966 | * via a WebView scene element.
967 | * @param varName Local variable name
968 | * @param newValue New value of variable
969 | */
970 | setLocal(varName: string, newValue: string): void
971 |
972 | /**
973 | * Set the global system clipboard.
974 | *
975 | * Test the value with:
976 | * ```js
977 | * var clip = global( 'CLIP' );
978 | * ```
979 | * @param text Clipboard text
980 | * @param appendFlag Should text be appended to current clipboard
981 | */
982 | setClip(text: string, appendFlag: boolean): boolean
983 |
984 | /**
985 | * Show an Android System Settings screen.
986 | * @param screenName must be one of **all**, **accessibility**, **addacount**,
987 | * **airplanemode**, **apn**, **app**, **batteryinfo**, **appmanage**,
988 | * **bluetooth**, **date**, **deviceinfo**, **dictionary**, **display**,
989 | * **inputmethod**, **internalstorage**, **locale**, **location**,
990 | * **memorycard**, **networkoperator**, **powerusage**, **privacy**,
991 | * **quicklaunch**, **security**, **mobiledata**, **search**, **sound**,
992 | * **sync**, **wifi**, **wifiip** or **wireless**.
993 | */
994 | settings(screenName: tkSettingsScreen): boolean
995 |
996 | /**
997 | * Set the system home screen wallpaper.
998 | * @param path Path to image file
999 | */
1000 | setWallpaper(path: string): boolean
1001 |
1002 | /**
1003 | * Enable or disable the Wifi radio (if present).
1004 | *
1005 | * Test wifi state with:
1006 | * ```js
1007 | * if ( global( 'WIFI' ) == "on" ) { doSomething(); }
1008 | * ```
1009 | * @param setOn On or off
1010 | */
1011 | setWifi(setOn: boolean): boolean
1012 |
1013 | /**
1014 | * Run the shell command *command*.
1015 | *
1016 | * Returns undefined if the shell command failed. It's maximum size is
1017 | * restricted to around 750K.
1018 | * @param command Command to run
1019 | * @param asRoot Will only have effect if device is rooted.
1020 | * @param timeoutSecs Time (seconds) to wait for task
1021 | */
1022 | shell(command: string, asRoot: boolean, timeoutSecs: number): string
1023 |
1024 | /**
1025 | * Show the named scene, creating it first if necessary.
1026 | * @param name Scene name
1027 | * @param displayAs one of **Overlay**, **OverBlocking**, **OverBlockFullDisplay**, **Dialog**, **DialogBlur**, **DialogDim**, **ActivityFullWindow**, **ActivityFullDisplay**, **ActivityFullDisplayNoTitle**
1028 | * @param hoffset percentage horizontal offset for the scene -100% to 100% (not relevant for full screen/window display types)
1029 | * @param voffset percentage vertical offset for the scene -100% to 100% (not relevant for full screen/window display types)
1030 | * @param showExitIcon display a small icon in the bottom right which destroys the scene when pressed
1031 | * @param waitForExit whether to wait for the scene to exit before continuing the script
1032 | */
1033 | showScene(
1034 | name: string,
1035 | displayAs: tkDisplayAs,
1036 | hoffset: number,
1037 | voffset: number,
1038 | showExitIcon: boolean,
1039 | waitForExit: boolean
1040 | ): boolean
1041 |
1042 | /**
1043 | * Shutdown the device.
1044 | *
1045 | * Requires a rooted device.
1046 | *
1047 | * See also: {@link reboot}
1048 | */
1049 | shutdown(): boolean
1050 |
1051 | /**
1052 | *
1053 | * @param mode
1054 | */
1055 | silentMode(mode: tkSilentMode): boolean
1056 |
1057 | /**
1058 | * Run a previously created [SL4A](https://code.google.com/p/android-scripting/) script.
1059 | * @param scriptName Script name
1060 | * @param inTerminal Open script in terminal
1061 | */
1062 | sl4a(scriptName: string, inTerminal: boolean): boolean
1063 |
1064 | /**
1065 | * Setting the system *Sound Effects* setting (sound from clicking on buttons etc.
1066 | * @param setTo On or off
1067 | */
1068 | soundEffects(setTo: boolean): boolean
1069 |
1070 | /**
1071 | * Enable or disable the speakerphone function.
1072 | * @param setFlag Enable or disable
1073 | */
1074 | speakerPhone(setFlag: boolean): boolean
1075 |
1076 | /**
1077 | * Expand or contract the system status bar.
1078 | * @param expanded **true** to expand
1079 | */
1080 | statusBar(expanded: boolean): boolean
1081 |
1082 | /**
1083 | * Specify whether the device should remain on when power is connected.
1084 | * @param mode Possible modes are **never**, **ac**, **usb**, **any**.
1085 | */
1086 | stayOn(mode: tkStayOnMode): boolean
1087 |
1088 | /**
1089 | * Stop tracking a location provider. This is only relevant when a
1090 | * getLocation function has been previously called with the keepTracking
1091 | * parameter set.
1092 | */
1093 | stopLocation(): boolean
1094 |
1095 | /**
1096 | * Turn off the display and activate the keyguard.
1097 | *
1098 | * Requires Tasker's Device Administrator to be enabled in Android settings.
1099 | */
1100 | systemLock(): boolean
1101 |
1102 | /**
1103 | * Whether the named Tasker task is currently running. Returns false if the
1104 | * task name is unknown.
1105 | * @param taskName Task name to check
1106 | */
1107 | taskRunning(taskName: string): boolean
1108 |
1109 | /**
1110 | * Auto-accept an incoming call (if there is one).
1111 | */
1112 | takeCall(): boolean
1113 |
1114 | /**
1115 | * Take a photo with the builtin camera.
1116 | *
1117 | * See also: action [Take Photo](https://tasker.joaoapps.com/userguide/en/help/ah_take_photo.html)
1118 | * @param camera 0 = rear camera, 1 = front camera
1119 | * @param fileName Name to save photo as
1120 | * @param resolution format WxH e.g. 640x840
1121 | * @param insertGallery whether to insert the resulting picture in the
1122 | * Android Gallery application
1123 | */
1124 | takePhoto(camera: tkCamera, fileName: string, resolution: string, insertGallery: boolean): boolean
1125 |
1126 | /**
1127 | * Simulate keyboard typing.
1128 | *
1129 | * Requires a rooted device.
1130 | * @param text Text to type
1131 | * @param repeatCount How many times to repeat typing
1132 | */
1133 | type(text: string, repeatCount: number): boolean
1134 |
1135 | /**
1136 | * Unpack a Zip archive into the parent directory of the archive.
1137 | * @param zipPath Path to zip archive
1138 | * @param deleteZipAfter If set, causes the zip archive to be deleted after
1139 | * successful unpacking.
1140 | */
1141 | unzip(zipPath: string, deleteZipAfter: boolean): boolean
1142 |
1143 | /**
1144 | * Enable or disable USB tethering.
1145 | *
1146 | * See also: action [USB Tether](https://tasker.joaoapps.com/userguide/en/help/ah_tether_usb.html)
1147 | * @param set Enable or disable
1148 | */
1149 | usbTether(set: boolean): void
1150 |
1151 | /**
1152 | * Cause the device to vibrate for the specified time.
1153 | * @param durationMilliseconds Length of vibration
1154 | */
1155 | vibrate(durationMilliseconds: number): void
1156 |
1157 | /**
1158 | * Cause the device to vibrate following the specified *pattern*
1159 | * @param pattern consists of a sequence of off then on millisecond
1160 | * durations e.g.
1161 | * ```
1162 | * 500,1000,750,1000
1163 | * ```
1164 | * wait for 500ms, vibrates 1000ms, wait for 750ms, then vibrate for 1000ms.
1165 | * */
1166 | vibratePattern(pattern: string): void
1167 |
1168 | /**
1169 | * Pause the script for the specified time.
1170 | *
1171 | * Warning: may cause some preceeding functions not to complete in some
1172 | * situations. If in doubt, use JavaScript setTimeout() instead.
1173 | * @param durationMilliseconds Length to wait
1174 | */
1175 | wait(durationMilliseconds: number): void
1176 |
1177 | /**
1178 | * Enable or disable Wifi tethering.
1179 | *
1180 | * See also: action [Wifi Tether](https://tasker.joaoapps.com/userguide/en/help/ah_tether_wifi.html)
1181 | * @param set Enable or disable
1182 | */
1183 | wifiTether(set: boolean): boolean
1184 |
1185 | /**
1186 | * Write *text* to *file* path.
1187 | * @param path Path to file
1188 | * @param text File contents
1189 | * @param append If *append* is specified, the text will be attached to the
1190 | * end of the existing file contents (if there are any).
1191 | */
1192 | writeFile(path: string, text: string, append: boolean): boolean
1193 |
1194 | /**
1195 | * Zip a file or directory.
1196 | * @param path Path to file to zip
1197 | * @param level the desired compression level from 1-9, with 9 resulting in
1198 | * the smallest file and the longest compression time.
1199 | * @param deleteOriginalAfter If *deleteOriginalAfter* is **true**, causes
1200 | * *path* to be deleted if the zip operation is successful.
1201 | */
1202 | zip(path: string, level: number, deleteOriginalAfter: boolean): boolean
1203 | }
1204 |
1205 | declare global {
1206 | const tk: TK;
1207 |
1208 | const alarmVol: TK["alarmVol"];
1209 | const audioRecordStop: TK["audioRecordStop"];
1210 | const audioRecord: TK["audioRecord"];
1211 | const browseURL: TK["browseURL"];
1212 | const btVoiceVol: TK["btVoiceVol"];
1213 | const button: TK["button"];
1214 | const callBlock: TK["callBlock"];
1215 | const callDivert: TK["callDivert"];
1216 | const callRevert: TK["callRevert"];
1217 | const call: TK["call"];
1218 | const callVol: TK["callVol"];
1219 | const carMode: TK["carMode"];
1220 | const clearKey: TK["clearKey"];
1221 | const composeEmail: TK["composeEmail"];
1222 | const composeMMS: TK["composeMMS"];
1223 | const composeSMS: TK["composeSMS"];
1224 | const convert: TK["convert"];
1225 | const createDir: TK["createDir"];
1226 | const createScene: TK["createScene"];
1227 | const cropImage: TK["cropImage"];
1228 | const decryptDir: TK["decryptDir"];
1229 | const decryptFile: TK["decryptFile"];
1230 | const deleteDir: TK["deleteDir"];
1231 | const deleteFile: TK["deleteFile"];
1232 | const destroyScene: TK["destroyScene"];
1233 | const displayAutoBright: TK["displayAutoBright"];
1234 | const displayAutoRotate: TK["displayAutoRotate"];
1235 | const displayTimeout: TK["displayTimeout"];
1236 | const dpad: TK["dpad"];
1237 | const dtmfVol: TK["dtmfVol"];
1238 | const elemBackColour: TK["elemBackColour"];
1239 | const elemBorder: TK["elemBorder"];
1240 | const elemPosition: TK["elemPosition"];
1241 | const elemTextColour: TK["elemTextColour"];
1242 | const elemTextSize: TK["elemTextSize"];
1243 | const elemText: TK["elemText"];
1244 | const elemVisibility: TK["elemVisibility"];
1245 | const enableProfile: TK["enableProfile"];
1246 | const encryptDir: TK["encryptDir"];
1247 | const encryptFile: TK["encryptFile"];
1248 | const endCall: TK["endCall"];
1249 | const enterKey: TK["enterKey"];
1250 | const exit: TK["exit"];
1251 | const filterImage: TK["filterImage"];
1252 | const flashLong: TK["flashLong"];
1253 | const flash: TK["flash"];
1254 | const flipImage: TK["flipImage"];
1255 | const getLocation: TK["getLocation"];
1256 | const getVoice: TK["getVoice"];
1257 | const global: TK["global"];
1258 | const goHome: TK["goHome"];
1259 | const haptics: TK["haptics"];
1260 | const hideScene: TK["hideScene"];
1261 | const listFiles: TK["listFiles"];
1262 | const loadApp: TK["loadApp"];
1263 | const loadImage: TK["loadImage"];
1264 | const local: TK["local"];
1265 | const lock: TK["lock"];
1266 | const mediaControl: TK["mediaControl"];
1267 | const mediaVol: TK["mediaVol"];
1268 | const micMute: TK["micMute"];
1269 | const mobileData: TK["mobileData"];
1270 | const musicBack: TK["musicBack"];
1271 | const musicPlay: TK["musicPlay"];
1272 | const musicSkip: TK["musicSkip"];
1273 | const musicStop: TK["musicStop"];
1274 | const nightMode: TK["nightMode"];
1275 | const notificationVol: TK["notificationVol"];
1276 | const performTask: TK["performTask"];
1277 | const popup: TK["popup"];
1278 | const profileActive: TK["profileActive"];
1279 | const pulse: TK["pulse"];
1280 | const readFile: TK["readFile"];
1281 | const reboot: TK["reboot"];
1282 | const resizeImage: TK["resizeImage"];
1283 | const ringerVol: TK["ringerVol"];
1284 | const rotateImage: TK["rotateImage"];
1285 | const saveImage: TK["saveImage"];
1286 | const say: TK["say"];
1287 | const scanCard: TK["scanCard"];
1288 | const sendIntent: TK["sendIntent"];
1289 | const sendSMS: TK["sendSMS"];
1290 | const setAirplaneMode: TK["setAirplaneMode"];
1291 | const setAirplaneRadios: TK["setAirplaneRadios"];
1292 | const setAlarm: TK["setAlarm"];
1293 | const setAutoSync: TK["setAutoSync"];
1294 | const setBTID: TK["setBTID"];
1295 | const setBT: TK["setBT"];
1296 | const setClip: TK["setClip"];
1297 | const setGlobal: TK["setGlobal"];
1298 | const setKey: TK["setKey"];
1299 | const setLocal: TK["setLocal"];
1300 | const settings: TK["settings"];
1301 | const setWallpaper: TK["setWallpaper"];
1302 | const setWifi: TK["setWifi"];
1303 | const shell: TK["shell"];
1304 | const showScene: TK["showScene"];
1305 | const shutdown: TK["shutdown"];
1306 | const silentMode: TK["silentMode"];
1307 | const sl4a: TK["sl4a"];
1308 | const soundEffects: TK["soundEffects"];
1309 | const speakerPhone: TK["speakerPhone"];
1310 | const statusBar: TK["statusBar"];
1311 | const stayOn: TK["stayOn"];
1312 | const stopLocation: TK["stopLocation"];
1313 | const systemLock: TK["systemLock"];
1314 | const systemVol: TK["systemVol"];
1315 | const takeCall: TK["takeCall"];
1316 | const takePhoto: TK["takePhoto"];
1317 | const taskRunning: TK["taskRunning"];
1318 | const type: TK["type"];
1319 | const unzip: TK["unzip"];
1320 | const usbTether: TK["usbTether"];
1321 | const vibratePattern: TK["vibratePattern"];
1322 | const vibrate: TK["vibrate"];
1323 | const wait: TK["wait"];
1324 | const wifiTether: TK["wifiTether"];
1325 | const writeFile: TK["writeFile"];
1326 | const zip: TK["zip"];
1327 | }
1328 |
--------------------------------------------------------------------------------