当前位置:网站首页>Autojs article proficient in detailed explanation of autojs script tutorial
Autojs article proficient in detailed explanation of autojs script tutorial
2022-07-24 07:59:00 【Cupster】
This article is based on readers' familiarity or understanding JavaScript
1. Basics
- Screen coordinate system , The upper left corner of the screen is the origin (0,0), To the right is x Positive axis , Down is y Positive axis
- Unit is px
- Most other grammars are related to JS Similar or consistent
2. Commonly used api
| function | function |
|---|---|
| click(x,y) | click(500,500) Click on the screen x=500px,y=500px The point of |
| press(x,y,mills) | press(200,200,1000) Hold down (200,200)1 Second |
| sleep(mills) | sleep(1000) Program pause 1 second |
| press(x,y,1); sleep(50); press(x,y,1) | double-click |
| swipe(x1,x2,y1,y2,t) | swipe(100,300,600,900,1000); from A spot (100,300) Slide to B spot (600,900) Time consuming setting 1 second |
| auto.waitFor() | Waiting to apply for accessibility , Generally used at the beginning of a script |
| Tap(x,y) | And click(x,y) equally ,Android7.0 The following uses , And we need root |
| Swipe(x1,x2,y1,y2,t) | And swipe(x1,y1,x2,y2,t) equally ,Android7.0 The following uses , And we need root |
| console.verbose | Grey log |
| console.info | Green log |
| console.warn | Blue log |
| console.error | Red log |
| toast(str) | Bubble tip ,str For content |
| serScreenMetrics(width,height) | Set the width and height of the script running screen The width is inconsistent , The coordinate value of the operation will be automatically scaled |
| var w = device.height | Get screen height px |
| var w = device.width | Get screen width px |
| console.show(); | Display console |
| console.hide(); | Hide the console |
| console.rawInput(); | Wait for console input 、 And wait for click ok |
| dialog.confirm(title ,content) | Pop up the confirmation box , Click OK to return to true, Click Cancel to return to false |
| engines.execScriptFile(path) | start-up path The corresponding script Available relative paths :./xx.js Script of the same directory |
| engines.stopAll() | Stop all scripts , Include yourself |
| exit() | Stop the current script |
| app.launchApp(appName) | adopt APP Name start app |
| app.launchApp(pkgName) | Start by package name app |
| app.uninstall(pkgName) | Uninstall by package name app |
| app.openUrl(url) | Open the browser , And turn on the specified url |
| back() | Return key function |
| home() | home Key function |
| random(min ,max) | Return random number [min ,max] |
| toastLog(message) | toast(str) and log(str) The merger of |
| device.vibrate(mills) | device.vibrate(1000) The phone vibrates 1 second |
| device.keepScreenOn(mill) | Keep your phone on , If the time is not set, it will be always on , Setup time , That is, the specified constant light time |
| setClip(text) | Set clipboard contents |
| getClip() | Get the contents of the pasteboard |
| setInterval(function(){} , mills) | Set the specified interval , Circulatory body of |
3. Native controls api
stay auto.js The software has the function of directly obtaining control information , stay auto.js Software homepage , Click on the top right corner , Open the side pull menu , The floating window in the approximate middle position opens . This auto.js The floating window of contains the function of obtaining control information . Click on the floating window and we can see 5 Features , The blue one in the middle is the function for viewing control information , After clicking , It will let you choose to use layout range analysis and layout hierarchy analysis
The main control information is id That is, the of the control id attribute ,text Control text properties ,bounds Control's border position ,desc The control of desc value , Some controls will put text Control empty , And write the above text desc value .clickable/longClickable Whether the control can be clicked / Long press , If the clickable by false Then clicking is useless .checked Control is checked ,depth At which level ,indexInParent Which number is in the parent control .
| api | function |
|---|---|
| id(“a”).text(“abc”).findOne().click(); | choice id The attribute is a Of ,text The attribute is abc Control for , Until you find a control that meets the above conditions , Click on it . |
| desc() | matching desc Control whose value is parameter |
| descContains(“cd”) | |
| descStartsWith() | |
| descEndsWith() | |
| descMatches() | Used to pass in regular expressions Match and find the corresponding control |
| text() | |
| textContains() | |
| textStartsWith() | |
| textEndsWith() | |
| textMatches() | |
| id() | |
| idContains() | |
| idStartsWith() | |
| idEndsWith() | |
| idMatches() | |
| className | |
| package | |
| clickable(true) | Click the selector |
| checkable() | Can I check |
| selected() | Selected or not |
| longClickable() | Can I press and hold |
| enabled() | Control is enabled - Selectors |
| scrollable() | Selectors : Whether the control can slide |
| editable() | Selectors : Control can be edited |
| - | - |
| bounds(x1,y1,x2,y2) | Control position range , The first two values are the coordinates of the upper left corner of the control rectangle , The last two values are the coordinates of the lower right corner of the control |
| boundsInside(x1,y1,x2,y2) | boundsInside(233,233,666,666) |
| filter(function(w){return w.text().length==10}) | Filter out text Attributes are 10 A character control |
| findOne() | Look for functions on the screen that match the previous control selector , Until it appears , And return the first control that appears , In addition, he can pass in a parameter — Maximum search time , Ascend the throne , If you haven't found it by the time , Go straight back to undifined, To continue the script |
| findOnce() | The function will only look for it once , If there is no , Then return directly null, He can also pass in a parameter , Used to write , You need to get the number of qualified content on the current screen , If the number on the current screen , Not enough to get , Then return to null |
| untilFind() | He will cycle through , At least one must be found before returning to the collection |
| find() | The selector is converted to a collection |
4. Control
| api | function |
|---|---|
| setText() | Input the contents in the box :id(“edit”).findOne().setText(“123456”); |
| Control .parent() | Get the parent control function of this function |
| child( Number one ) | Get his several child controls , Note that the serial number starts from zero |
| children() | Used to return all child controls of this control |
| findByText(str) | Need to pass in a passage < character string >, This function returns all of its child controls or grandchildren text perhaps desc Property contains all controls of this text |
边栏推荐
- Workspace creation
- *Code understanding * common function parsing in pytoch
- Facing Tencent (actual combat) - Test Development - detailed explanation of interns (face experience)
- Selenium basic knowledge multi window processing
- Learning to track at 100 FPS with deep progression networks
- Example of dictionary
- Debug No4 use renderdoc to troubleshoot bugs
- A simple mobile terminal todo
- Implement a queue with two stacks.
- Tools for data visualization
猜你喜欢

Implement a queue with two stacks.

Project practice - document scanning OCR recognition

Facing Tencent (actual combat) - Test Development - detailed explanation of interns (face experience)

Selenium basic knowledge automatically login Baidu Post Bar

JMeter stress test index interpretation

Selenium basic knowledge automatic search

Devops essay

避坑,职场远离PUA,PUA常见的套路与话术你得了解一下!

Starting from scratch C language intensive Part 3: Functions

Hcip 13th day notes
随机推荐
Intelligent robots and intelligent systems (Professor Zheng Zheng of Dalian University of Technology) -- 2. Mobile Robot Perception
Installation and use of CONDA
Markdown basic grammar learning
Hcip day 8 notes
POJ3278抓住那头牛题解
Use JMeter to analyze and test the lottery probability of the lottery interface
P3916图的遍历 题解
[target detection] IOU (intersection and combination ratio)
Selenium basic knowledge automatic login QQ space
SIFT feature point extraction
Vertex buffer and shader (the cherno + leranopongl) notes
hcip第十三天笔记
Hcip day 9 notes
Starting from scratch C language intensive Part 3: Functions
Collection of linked list topics
Have you seen the interview questions of VR major? Trust me, it's absolutely useful
A simple mobile terminal todo
Selenium basic knowledge debugging method
(dkby) DFL learning notes
Debug No3 multi texture overlay