Your first script in 10 minutes
Write, run and fix your first script in the Playground: a message, then a button tapped thanks to an image capture.
Last reviewed 2 November 2026
By the end of this page you will have run a script on your phone, read its output, and made AppsMobs tap a button you captured yourself. ⏱ 10 minutes.
Before you start
- AppsMobs is installed and you are signed in: Installing AppsMobs, Sign in and activate your licence.
- A phone (or an emulator) is plugged in and shows as Free on the Dashboard: Connect a phone or an emulator.
- No Python knowledge needed. You copy, and every line is explained.
- 1
Open the Playground
Click Playground in the sidebar, under Build. This is where you write your scripts.
1Playground A welcome screen asks What do you want to automate? and offers four choices: Start from an example, Build with blocks, Describe it to the AI, Open a script. For this tutorial, click Or start from a blank page.
You now see the code editor, with the script name at the top (New script, mark 1), the Code / Blocks switch (mark 2), the Run on selector (mark 3) and the Run (mark 4), Stop (mark 5), Save (mark 6) buttons.
1Script name2Code / Blocks switch3Run on4Run5Stop6Save - 2
Write a first script without images
Make sure the Code mode is active (at the top, next to Blocks). Click in the code area and type this:
log("Script started") press_home() wait(2) log("Back on the home screen")What these lines do:
log("...")writes a message in the Output panel. It is your way of seeing what the script does.press_home()presses the phone's Home button.wait(2)waits 2 seconds. The number is in seconds.
There is nothing to import: functions like
logorpress_homeare already known to the Playground. They are all explained in the function reference. - 3
Choose the device
Click Run on (the device selector, in the middle of the top bar). A Run the script on window opens with the list of your devices.
Tick your phone. Your choice is remembered for next runs. If you tick nothing, AppsMobs asks which device at each run.
If the list is empty, the message is No device connected. Plug a phone in over USB (USB debugging on) or start an emulator.: go back to Connect a phone or an emulator.
- 4
Run the script
Click Run (or press F5).
What happens: the Output panel opens at the bottom. First you see Launching on followed by your device name, then your messages, each one preceded by the time. On the phone, the home screen shows up.
How to know it worked: the status goes from Starting… to Running on and then Finished in followed by the duration. While it runs, you can click Stop (Shift + F5) to interrupt it.
The full detail stays available in the Console: the Open the app Console button of the Output panel takes you there.
You can still read the output later
Copy the output copies the text, Clear empties the panel. At the next run, a line separates old lines from new ones.
- 5
Save the script
Press Ctrl + S (or click Save). A save window opens (its title is in French, Sauvegarder le script AppsMobs), already placed in your scripts folder:
Documents\AppsMobs\Scripts.Give it a name, for example
my_first_script.py, and confirm. Under the script name, Not saved yet is replaced by the file path.Keep this folder in mind: it is where you will put the button image in the next step.
- 6
Capture the phone screen
To tap a button, the script needs a small picture of that button. On your phone, show the screen that contains the button you want to tap (any clearly visible button, for example an icon on the home screen).
In the Playground, click the ⋯ button (More actions) on the right of the top bar, then, in the Tools group, Device screenshot. The shortcut is F9.
If several devices are plugged in, a window asks which one to capture. Otherwise the capture starts right away.
A Screenshot saved window appears with the file name and the question Open the screenshot in Paint to crop?. Click Yes.
The whole capture is saved in your screenshots folder (
Documents\AppsMobs\Screenshots), under a name likedevice-id_date.png. - 7
Crop the button and save it next to the script
In Paint:
- Click the Select tool, then draw a rectangle around only the button, as tight as possible.
- Click Crop. Only the button remains.
- Choose File, Save as, PNG picture.
- Go to
Documents\AppsMobs\Scripts(your script's folder) and name the filebutton.png.
A good image
- Take the button alone, without the background around it. A small, very recognisable piece works better than a large area.
- Avoid parts that change (a counter, a date).
- Take the capture on a device with the same resolution as the one that will run the script.
- The name must end with
.pngand you write it exactly as is in the script (capitals included).
Where to put the file: AppsMobs looks for the image first in the script's folder, then in
Documents\AppsMobs\Scripts\img. Either works. If you save it in neither, the script stops with an error message (see below). - 8
Make it tap the button
Go back to the Playground. Replace the script content with:
log("Looking for the button") if tap_image("button.png", timeout=15): log("Button tapped") else: log("Button not found after 15 seconds")tap_image("button.png", timeout=15)waits up to 15 seconds for the image to appear, then taps it. It answers true if the button was tapped, false otherwise.if ... else ...chooses what to do depending on the answer. The lines indented by 4 spaces underifandelseare the ones that run in each case.
Press Ctrl + S, then Run.
How to know it worked: on the phone, the button is tapped, and the Output shows Button tapped.
The same script with a text instead of an image
If the button carries a text that Android can read, you do not need an image:
log("Waiting for the text")
if wait_text("Settings", timeout=15):
tap_text("Settings")
log("Text tapped")
else:
log("Text not found")
wait_text waits for an element to display this text, tap_text taps it. Text drawn inside an image (common in games) cannot be read this way: use tap_image then.
Repeating an action
Add a loop to start over. This example is the one from the Playground (welcome screen, Start from an example), with your image:
for i in range(10):
log(f"Round {i + 1}/10")
tap_image("button.png")
wait(2)
log("Done!")
for i in range(10) repeats the indented lines ten times. Here tap_image waits for the image (30 seconds by default) before the next round.
What this script does not do
If the image never appears, tap_image waits, and then the script keeps going anyway: it does not stop by itself on a failure. Always test the answer (if tap_image(...)) when what comes next depends on it.
Not working?
| What you see | Likely cause | What to do |
|---|---|---|
| No device connected: plug a phone in (USB debugging on) or start an emulator, then press Run again. | No device detected. | Connect a phone or an emulator, check Free on the Dashboard, run again. |
| The window For your security, this script cannot be executed. | The safety check found forbidden code (for example import os). | Remove the import: functions do not need one. Details: Writing a Python script. A syntax mistake can also trigger this window: read the detail shown. |
image introuvable : button.png (cherchée dans le dossier du script et dans Scripts/img) (the message is in French) | The file is in the wrong place, or the name differs. | Save the script, put button.png in the same folder or in Scripts\img, check the name and the .png extension. |
| The script ends but the button is not tapped (Button not found…) | The image does not look enough like the screen. | Redo the capture tighter around the button, on a device with the same resolution, or lower the confidence a little: tap_image("button.png", conf=0.7). |
NameError: name 'click' is not defined | The function name does not exist. | Names are English: tap, tap_image, wait. See the reference. |
| Stopped with an error after … | The script crashed. | Read the last lines of the Output: they give the reason. The full detail is in the Console. |
| Screenshot failed | The device cannot be reached any more. | Check the cable and USB debugging, then capture again. |
| Run has no effect, with an expired licence | AppsMobs is in read-only mode. | Sign in and activate your licence. |
| The script runs too long | A wait is long. | Click Stop (Shift + F5). |
What next
- Build without code: the block editor: the same thing by dragging blocks.
- Writing a Python script: the rules, the images, good habits.
- Function reference: the 87 available functions.