--- name: tasker-xml description: Create Tasker profiles and tasks via XML for Android automation. Use when adding new Tasker functionality, creating Intent Received handlers, or building automation that integrates with the rho.tasker extension. --- # Tasker XML Creation Create importable Tasker profiles and tasks via XML files. ## Output Location Write XML files to `/storage/emulated/0/Download/` for easy import: ``` /storage/emulated/0/Download/MyProfile.prf.xml ``` ## File Suffixes - `.prf.xml` - Profile with linked task(s) - `.tsk.xml` - Standalone task - `.prj.xml` - Full project ## Import Instructions 1. Open Tasker app 2. For profiles: Long press PROFILES tab → Import Profile 3. For tasks: Long press TASKS tab → Import Task 4. Navigate to Download folder, select the XML file ## XML Structure ### Basic Profile with Task ```xml 1706900000000 1706900000000 1 1 Profile Name 1706900000000 1706900000000 1 Task Name 6 ``` **Important:** Profile `` must match Task ``. ## Event Codes (for Profile triggers) Use inside `` with ``: | Code | Event | |------|-------| | 599 | Intent Received | | 461 | Notification | | 463 | New Window | | 2078 | App Changed | | 3050 | Variable Set | ### Intent Received Event (code 599) ```xml 599 rho.tasker.my_action ``` - `arg0`: Intent action name (e.g., `rho.tasker.open_app`) - `arg1`: Priority (0 = normal) - `arg2`: Stop event (0 = no) - `arg3`: Cat (category filter, usually empty) - `arg4`: Data filter (usually empty) ## Action Codes (for Task steps) Use inside `` with ``: ### Common Actions | Code | Action | Key Args | |------|--------|----------| | 20 | Launch App | arg0=app name | | 25 | Go Home | (none) | | 30 | Wait | arg0=hours, arg1=mins, arg2=ms, arg3=secs | | 37 | If | arg0=condition | | 38 | End If | (none) | | 43 | Else | (none) | | 104 | Browse URL | arg0=url | | 123 | Run Shell | arg0=command, arg1=use root, arg2=timeout | | 126 | Return | (stops task) | | 130 | Perform Task | arg0=task name | | 137 | Stop | (stops task) | | 410 | Write File | arg0=path, arg1=content | | 547 | Variable Set | arg0=name, arg1=value | | 548 | Variable Clear | arg0=name | | 549 | Variable Add | arg0=name, arg1=value | | 550 | Variable Subtract | arg0=name, arg1=value | | 559 | Flash | arg0=text | ### AutoInput Actions (code -1) AutoInput uses plugin action code `-1` with Bundle configuration. #### UI Query (Read Screen) ```xml -1 Check Screen Configuration: Check Screen java.lang.String true java.lang.Boolean com.joaomgcd.autoinput com.joaomgcd.autoinput.activity.ActivityConfigUIQuery ``` After this action, these variables are available: - `%aitext()` - Array of visible text - `%aiid()` - Array of element IDs - `%aicoords()` - Array of x,y coordinates - `%aiapp` - Current app package #### Click by Text ```xml -1 Action: Click [ Type:Text Value:%target ] java.lang.String click java.lang.String %target java.lang.String text java.lang.String true java.lang.Boolean com.joaomgcd.autoinput com.joaomgcd.autoinput.activity.ActivityConfigAction ``` #### Click by Coordinates ```xml -1 Action: Click [ Type:Point Value:%xcoord,%ycoord ] java.lang.String click java.lang.String %xcoord,%ycoord java.lang.String point java.lang.String true java.lang.Boolean com.joaomgcd.autoinput com.joaomgcd.autoinput.activity.ActivityConfigAction ``` ## Action Examples ### Variable Set (code 547) ```xml 547 %my_var my value ``` ### Launch App (code 20) ```xml 20 Telegram ``` ### Wait (code 30) ```xml 30 ``` - arg0=hours, arg1=minutes, arg2=milliseconds, arg3=seconds ### Write File (code 410) ```xml 410 /storage/emulated/0/rho/result.txt Content to write Can be multiline Variables work: %myvar ``` ### Flash (code 559) ```xml 559 Toast message here ``` ### Go Home (code 25) ```xml 25 ``` ### Run Shell (code 123) ```xml 123 echo "Hello" %output %err_output ``` ### If/Else/End If (codes 37, 43, 38) ```xml 37 %direction down 43 38 ``` ## Rho Integration Pattern For rho.tasker.* handlers, use this standard pattern: ```xml 1706900000000 1706900000000 1 1 Rho Action Name 599 rho.tasker.action_name 1706900000000 1706900000000 1 Rho Action Handler 6 547 %result_file %result_file -1 Check Screen Configuration: Check Screen java.lang.String true java.lang.Boolean com.joaomgcd.autoinput com.joaomgcd.autoinput.activity.ActivityConfigUIQuery 410 %result_file %aiapp ~~~ %aicoords() ~~~ %aiid() ~~~ %aitext() ~~~ %err ``` ## Result File Format The rho.tasker extension expects results in this format: ``` app_name ~~~ x1,y1,x2,y2,... ~~~ id1,id2,... ~~~ text1|||text2|||... ~~~ error_message_or_empty ``` Use `%aiapp`, `%aicoords()`, `%aiid()`, `%aitext()` from AutoInput. ## Tips 1. **Action numbering**: Actions use `sr="act0"`, `sr="act1"`, etc. Sequential. 2. **Profile/Task IDs**: Use unique IDs (100+) to avoid conflicts with existing Tasker config. 3. **Intent extras**: Variables from intent extras are automatically available with same name (e.g., `%app_name` from intent extra `app_name`). 4. **Test incrementally**: Start with a Flash action to verify the profile triggers, then add complexity. 5. **Debugging**: Add Flash actions to show variable values during development.