# Luck in Wechat **Repository Path**: gl0930/luck_in_wechat ## Basic Information - **Project Name**: Luck in Wechat - **Description**: No description available - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 8 - **Created**: 2020-02-27 - **Last Updated**: 2021-02-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Luck in Wechat #### Description 年前发了个简单介绍在[blog](https://www.cnblogs.com/chilliegg/p/12177535.html),现在抽空将完整脚本上传在此。 这是一个autoJS的练手脚本,应用场景是自动抢微信红包。大致逻辑为自动检测未读消息(群或个人) --> one by one 打开未读消息 --> 无效红包过滤 --> 自动打开可抢红包并领取 --> 退出检测下一条未读。 #### Software Architecture 任意Android手机一部,安装好微信和AutoJS apk即可 #### Installation - 安装auto.js apk - 导入该js脚本 - 在auto js设置中开启悬浮窗 - 手机设定无障碍模式 - 打开微信,在悬浮窗中启动和结束脚本 #### Instructions ##### 逻辑思路和关联到的控件信息 i. 检查是否有红包?循环上滑3次屏幕 ii. 点击红包消息 LinearLayout(clickable=true && depth=13 && id=atb) iii. 检测红包是否可领?有无[开] iv. 开红包【开】 Button(desc='开' && id=dan && depth=9) v. 取得金额 TextView(depth=13 && id=d62 && text=【金额】) vi. 返回聊天界面 LinearLayout(depth=7 && id=m0 && clickable=true) vii. 返回微信首页 LinearLayout(depth=9 && id=lr && clickable=true) ##### Hints 1. 如果一个控件本身无法通过click()点击,那么我们可以利用bounds()函数获取其坐标,再利用坐标点击。例如: var b = desc("打开侧拉菜单").findOne().bounds(); click(b.centerX(), b.centerY());  //如果使用root权限,则用 Tap(b.centerX(), b.centerY()); 2. 小心使用find(),findOne()等,注意仔细看原文档,否则会莫名其妙找不到控件或被阻塞 //please avoid to use findOne() as it will jam until get one UIObject // we could use findOne(500) or findOnce() to instead if need ##### 挖两个坑 - 若结合VSCode可以一部电脑控制多台手机同步执行一个脚本。 - 若未来有其他微信自动化需求,如自动刷朋友圈,自动发群消息等都可以参照实现,so easy的。。。 #### Contribution 1. Fork the repository 2. Create Feat_xxx branch 3. Commit your code 4. Create Pull Request #### Gitee Feature 1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md 2. Gitee blog [blog.gitee.com](https://blog.gitee.com) 3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) 4. The most valuable open source project [GVP](https://gitee.com/gvp) 5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) 6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)