First Example: the usage of AnkuLua in real application
Sept 3, 2015 13:44:32 GMT
Eebado, adrian1206, and 1 more like this
Post by AnkuLua on Sept 3, 2015 13:44:32 GMT
Here is a simple example to demonstrate the usage of AnkuLua.
Note: All the following operations are in your Android device.
Note for rooted devices:
If your device is root, remember to turn off superuser notification and log.
Superuser notification will popup notification when capturing screenshot. That will make the result incorrectly possibly.
Superuser log creates many files and consume inodes. It will cause trouble in long time.
Step one: Install calculator plus and script
In this example, we need to install "Calculator Plus Free".
Please click the above link and install it in your Android device.
Then download the script zip file directly on device/emulator browser (note: not on PC browser). (Another download link)
Emulator Users:
If the downloaded file is bin, please change it to zip.
Use any file explorer App to change the name.
Or use ES File Explorer.
Long press the file, then there is "rename" in the bottom.
Suggest to download with Chrome browser. Again, use device/emulator Chrome app, not PC Chrome.
Step two: Choose the script
Now run AnkuLua. You can see the following picture after root/daemon check.
Now tap the "Select Script" button, then the file browser shows.
Then select the download "calculator_plus.zip". The download zip file is under /sdcard/Download directory normally.
AnkuLua will ask you which directory to unzip to, please select /sdcard/AnkuLua.
Now the "Script to be executed" change to "example1.lua".
Now tap the "Start Service" button. And a translucent "play" button shows on the lower left corner.
MIUI Users:
If the translucent "play" button doesn't show.
Change following setting. MIUI: Settings-->installed app-->AnkuLua-->Permission manager-->Display pop-up window-->Accept
Check if there are two USB debugging options in "Developer options". If yes, enable both of them.
Step three: run it
Now switch back to calculator plus and keep your device orientation to landscape.
Tab the "play" button on the lower left corner.
You can see that following buttons are tapped sequentially, 6 + 9 - 7 =
Here is the video of the whole process.
MIUI Users: If the "Hello World!" showed, but the numbers are not clicked.
Solution:Turn on USB debugging in developer options.
During turning on, MIUI may keep warning and you should keep confirming.
Check if there are two USB debugging options in "Developer options". If yes, enable both of them.
What are inside calculator_plus.zip file
Inside the zip file, the top folder is "calculator_plus".
There are a folder "image" in the "calculator_plus" folder.
Look inside the "image" folder, you can find many png image files. Each image file corresponds to one button in Calculator Plus App.
Those images files are used by the script to find from the screen.
There is only one script in the zip file, "example1.lua".
Here is the content with line numbers.
The script is written in lua version 5.1. For more information about lua, go to lua 5.1 reference manual.
For lua, a comment starts anywhere with a double hyphen ( -- ) and runs until the end of the line.
Therefore, line 1 and 5 are comments.
Line 2 sets the width of the screen from which images were captured.
Line 3 sets the script width of the screen according to which the script was written.
Those two lines are very important. They make the script could be run correctly in devices of different resolution.
From line 6 to 11, click functions are called.
click function behaves searching the given image and click the found object.
Finally, "Hello World!" is printed as tradition.
Note that any print will be shown in a dialog only after the script completed.
That's it. We have our first example run.
[Next]: Script Development Tools
[Previous]: Daemon installation
[Home]: AnkuLua Introduction
Note: All the following operations are in your Android device.
Note for rooted devices:
If your device is root, remember to turn off superuser notification and log.
Superuser notification will popup notification when capturing screenshot. That will make the result incorrectly possibly.
Superuser log creates many files and consume inodes. It will cause trouble in long time.
Step one: Install calculator plus and script
In this example, we need to install "Calculator Plus Free".
Please click the above link and install it in your Android device.
Then download the script zip file directly on device/emulator browser (note: not on PC browser). (Another download link)
Emulator Users:
If the downloaded file is bin, please change it to zip.
Use any file explorer App to change the name.
Or use ES File Explorer.
Long press the file, then there is "rename" in the bottom.
Suggest to download with Chrome browser. Again, use device/emulator Chrome app, not PC Chrome.
Step two: Choose the script
Now run AnkuLua. You can see the following picture after root/daemon check.
Now tap the "Select Script" button, then the file browser shows.
Then select the download "calculator_plus.zip". The download zip file is under /sdcard/Download directory normally.
AnkuLua will ask you which directory to unzip to, please select /sdcard/AnkuLua.
Now the "Script to be executed" change to "example1.lua".
Now tap the "Start Service" button. And a translucent "play" button shows on the lower left corner.
MIUI Users:
If the translucent "play" button doesn't show.
Change following setting. MIUI: Settings-->installed app-->AnkuLua-->Permission manager-->Display pop-up window-->Accept
Check if there are two USB debugging options in "Developer options". If yes, enable both of them.
Step three: run it
Now switch back to calculator plus and keep your device orientation to landscape.
Tab the "play" button on the lower left corner.
You can see that following buttons are tapped sequentially, 6 + 9 - 7 =
Here is the video of the whole process.
MIUI Users: If the "Hello World!" showed, but the numbers are not clicked.
Solution:Turn on USB debugging in developer options.
During turning on, MIUI may keep warning and you should keep confirming.
Check if there are two USB debugging options in "Developer options". If yes, enable both of them.
What are inside calculator_plus.zip file
Inside the zip file, the top folder is "calculator_plus".
There are a folder "image" in the "calculator_plus" folder.
Look inside the "image" folder, you can find many png image files. Each image file corresponds to one button in Calculator Plus App.
Those images files are used by the script to find from the screen.
There is only one script in the zip file, "example1.lua".
Here is the content with line numbers.
The script is written in lua version 5.1. For more information about lua, go to lua 5.1 reference manual.
For lua, a comment starts anywhere with a double hyphen ( -- ) and runs until the end of the line.
Therefore, line 1 and 5 are comments.
Line 2 sets the width of the screen from which images were captured.
Line 3 sets the script width of the screen according to which the script was written.
Those two lines are very important. They make the script could be run correctly in devices of different resolution.
From line 6 to 11, click functions are called.
click function behaves searching the given image and click the found object.
Finally, "Hello World!" is printed as tradition.
Note that any print will be shown in a dialog only after the script completed.
That's it. We have our first example run.
[Next]: Script Development Tools
[Previous]: Daemon installation
[Home]: AnkuLua Introduction