当前位置:网站首页>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 |
边栏推荐
- (dkby) DFL learning notes
- [matlab] (IV) application of MATLAB in linear algebra
- QT | string generation QR code function
- Do you know the use of string?
- Intelligent robots and intelligent systems (Professor Zhengzheng of Dalian University of Technology) -- 3. Industrial robots
- rbm 对比散度
- Function analysis of e-commerce website development and construction
- Selenium use
- A Knight‘s Journey题解
- Project practice - document scanning OCR recognition
猜你喜欢

Kubernetes: (I) basic concepts

Image feature Harris corner detection
![2022-07-23: given n items, each item has weight (w[i]) and value (v[i]), only two items can be selected at most, and the weight does not exceed bag. What is the maximum return value? N <= 10^5, w[i] <](/img/f4/ba2706e93f042dd8b110fac0d873c8.png)
2022-07-23: given n items, each item has weight (w[i]) and value (v[i]), only two items can be selected at most, and the weight does not exceed bag. What is the maximum return value? N <= 10^5, w[i] <

Installation and use of Zen path & defect report & defect operation

DevOps随笔

EZDML逆向工程导入数据库分析实操教程
![[matlab] (III) application of MATLAB in Higher Mathematics](/img/ff/72b13fb597d5bdf3a989dd86cb6888.png)
[matlab] (III) application of MATLAB in Higher Mathematics

Vertex buffer and shader (the cherno + leranopongl) notes

Opencv project practice - credit card recognition

【MATLAB】(四)MATLAB在线性代数中的应用
随机推荐
The growth path of software testing
The vision group of Hegong University Sky team trained day3 - machine learning, strengthened the use of Yolo models, and learned pumpkin books and watermelon books
Detailed explanation of VAO
Multiple optimization methods print prime numbers between 100 and 200
One click Copy and import of web interface data into postman
A simple mobile terminal todo
Do you want to have a robot that can make cartoon avatars in three steps?
hcip第八天笔记
*Code understanding * common function parsing in pytoch
Intelligent robots and intelligent systems (Professor Zhengzheng of Dalian University of Technology) -- 3. Industrial robots
Appium use
NFT是什么?一篇文章搞懂NFT的概念
Selenium basic knowledge debugging method
The difference between get and post
Intelligent robots and intelligent systems (Professor Zhengzheng of Dalian University of Technology) -- 4. Autonomous robots
QT | string generation QR code function
*Project recurrence * project implementation of thesis based on contextbasedemotionrecognitionusingematicdataset
GBK code in idea is converted to UTF-8 format ctrl+c+v one second solution perfect solution for single code file escape
55. Jumping game
Continuous learning, lifelong learning, episodic memory, memory module paper summary -- gradient episodic memory promotes continuous learning