Ah ~~ ah ~~ who sent red envelopes in the group again?


Do we often miss a lot of red envelopes during work and study? It feels like hundreds of millions have passed us by. At a moment I seem to see a red envelope, but helpless feeling single 30 years of hand speed or not as good as others!


Being a geek is unbearable!


preface



Xposed framework for grabbing a red envelope is a magic weapon, but things have two aspects although it is convenient for us to grab a red envelope but the premise is to need our phone root, so for the Apple phone will have to jailbreak.


Whether jailbreak or mobile phone root, will have certain risks to our mobile phones. So is there another way to grab a red envelope? you need Python

Environment configuration



Operating system: Windows Mobile operating system: Android Python version: 3.7



Implementation steps



To identify the messages in wechat, whether they are red packets or ordinary information, we judge by the element identification of chat messages. Here we use the “Airtest IDE” tool to achieve.

Step 1: Open your phone and enter the wechat group

Step 2: Identify wechat red envelopes

Step 3: Perform the action of grabbing red envelopes



Preparations for





Note: In the process of identifying wechat messages or red packets, we use the Airtest IDE tool here


Step 1: Turn on the PHONE’s USB debugging


After we turn on USB debug in developer mode. You can verify that adb works properly with Airttest IDE



Download and install Airtest IDE



AirtestIDE: cross-platform UI automated test editor


You can search the official website of Baidu to download the AirtestIDE


The Airtest IDE interface is shown below



To automate an Android app using the AirtestIDE, the first step is to connect to an Android device.

Step 1: Connect to a real Android machine


Step 2: Connect the RESH ADB button in the panel and the device list will refresh


Step 3: Click Connect of the corresponding device in the list to complete the connection


Process of grabbing red envelopes



Enter wechat, Tab on the left. Choose wechat group to grab red envelopes

In the AirtestIDE, you can pause and freeze the current UI tree to view a UI control precisely. Let’s analyze the element identification in the page first.

In the AirtestIDE, you can check the controls in a tree structure and page out the page



Then the red packets are identified in the group. Grab red packets



Next, you need to identify the element identifier of the “open” character in the red envelope



Now that we have the basic identity and elements, here is the core code



subsequent





Some children may find it troublesome to install the Airtest IDE tool. Python is so powerful that we can do without it. At this time, students need to install a third-party module pocoui


pip install pocouiCopy the code


AirtestIDE when creating a project, select Android for the device type and generate an initialization code


We also need to include this initialization code in our own Python code.


It is important to make sure that the phone is connected to the computer and that adb commands work properly when executing the program.


The core code

Code in the public number, we can focus on ~