Thursday, February 20, 2025

用QPython实现使用android的自动化操作[AutoPy]

Qpython AutoPy.py作者记录

使用方法:

1.安装我的AutoPy.apk

1.1 授权无障碍辅助权限(重要)

1.2 授权文档读写权限(重要)

2.点击安装Dian模块

3.打开开发者选项的显示指针位置

4.测试点击,测试拖动,

1150532-20200103140724768-1082716535.png

如图则可以正常使用

qpython里面的使用方法:

在qpython中使用,第一步要导入Dian文档,该文档目前共有两个方法,一个是实现点击,一个是实现拖动的,在这两个功能的配合下可以完成大部分自动化操作

1.点击:(方法名:tap(x,y))

#第一个参数x为,点击屏幕上的x坐标

#第二个参数y为,点击屏幕上的y坐标

#使用方法为:

improt Dian#导入Dian文档

Dian.top(100,100)#点击x:100,y:100的屏幕坐标

#可以实现点击

7109acf91b354e0cd98fc9cf6866f19a1f5.png

如图所示返回执行结果

2.滑动、拖动(方法名:swipe(x1,y1,x2,y2))

#第一个参数x1为,起点屏幕上的x1坐标

#第二个参数y1为,起点屏幕上的y1坐标

#第三个参数x2为,终点屏幕上的x2坐标

#第四个参数y2为,终点屏幕上的y2坐标

#使用方法为:

improt Dian#导入Dian文档

Dian.swipe(100,100,200,200)#将坐标x:100,y:100 拖到x:200,y:200坐标

1150532-20200103143619574-59860131.png

部分android_java源代码解析:

public void onAccessibilityEvent(AccessibilityEvent event)

{

if (flag == 0)

{

flag = 1;

new Thread() {

public void run()

{

while (true)

{

//System.out.println("xxx");

try

{

String fileName = "/sdcard/AutoPy.config";

String ret = "";

FileInputStream fis = new FileInputStream(fileName);

int len = fis.available();

byte []buffer = new byte[len];

Thread.sleep(10);

fis.read(buffer);

ret = EncodingUtils.getString(buffer, "UTF-8");

fis.close();

String [] stringArr= ret.split(",");

if (stringArr[0].equals("0"))

{

System.out.println("是零模式");

GestureDescription.Builder builder = new GestureDescription.Builder();

Path p = new Path();

p.moveTo(Integer.parseInt(stringArr[1]), Integer.parseInt(stringArr[2]));//坐标

//p.lineTo(200,200);

builder.addStroke(new GestureDescription.StrokeDescription(p, 0, 50));

dispatchGesture(builder.build(), null, null);

writeTxt("/sdcard/AutoPy.config", "执行成功");

}

if (stringArr[0].equals("1"))

{

System.out.println("是一模式");

GestureDescription.Builder builder = new GestureDescription.Builder();

Path p = new Path();

p.moveTo(Integer.parseInt(stringArr[1]), Integer.parseInt(stringArr[2]));//坐标

p.lineTo(Integer.parseInt(stringArr[3]), Integer.parseInt(stringArr[4]));

builder.addStroke(new GestureDescription.StrokeDescription(p, Integer.parseInt(stringArr[5]), Integer.parseInt(stringArr[5])));

dispatchGesture(builder.build(), null, null);

writeTxt("/sdcard/AutoPy.config", "执行成功");

}

}

catch (Exception e)

{

e.printStackTrace();

//Toast.makeText("").show();

writeTxt("/sdcard/AutoPyFalse.info", e.toString());

}}

}

}.start();

}

}

这里是监控文档变化的实现

python端代码:

利用文档来实现交互通信(后期会改成本地的socket通信)

importtimedef swipe(x1,y1,x2,y2,t=1000):

f=open('/sdcard/AutoPy.config','w+')

f.write('1,'+str(x1)+','+str(y1)+','+str(x2)+','+str(y2)+','+str(t))

f.close()for i in range(10000):

o=open('/sdcard/AutoPy.config','r').read()if o=='执行成功':break

print('[AutoPy]滑动执行成功')

time.sleep(0.0023*t)deftap(x,y):

f=open('/sdcard/AutoPy.config','w+')

f.write('0,'+str(x)+','+str(y))

f.close()for i in range(10000):

o=open('/sdcard/AutoPy.config','r').read()if o=='执行成功':break

print('[AutoPy]点击执行成功')

time.sleep(0.1)

#作者sunny开始学坏

本文完(^_^)

需要AutoPy.apk文档的可以加群

 https://blog.csdn.net/weixin_39582656/article/details/110374533

Tuesday, February 18, 2025

在树莓派安卓上用Qpython的pyserial读取串口数据步骤

 1. 下载KonstaKANG-rpi-magisk-v28.0.zip和Magisk-v28.0.apk并设置系统重启到twrp模式,安装twrp,重启后安装,安装完成后启动到system,安装apk,完成app root。

2. 安装termux终端,并执行su、chmod 777 ttyACM0. 也可以顺便用pkg install python安装python和temux-boot。

3. 硬件方面购买Ai离线语音模块,可以收发RS485串口数据以及RS485转USB转换头,连接两者。应用天问软件生成离线语音模型并下载。

4.在安卓系统安装qpython及Autopy.apk。在temux终端设置通过su及chmod设置tty*设备访问权限,编写AI语音发送串口数据到树莓派的代码。

5. 设置安卓自启动代码。

 

安卓上qpython安装模块比如pyserial

 Modules can be installed in QPython3 using pip. What you have to do is ..

Import pip

Then

pip.main([‘install','module name'])

For example if u want to install numpy then this will look like…

import pip

pip.main([‘install','numpy'])

https://www.quora.com/How-do-I-install-NumPY-or-any-other-modules-in-QPython3-in-Android


Sunday, February 9, 2025

装有启动盘的U盘或SD卡怎么格式化

1. 先用Diskgenius删除所有分区。

2. 在我的电脑-管理-磁盘管理里,新建卷并格式化。

3. 在资源管理器里格式化为NTFS格式。

解决windows下 cd 无法切换盘符目录

在windows下, 打开cmd.exe, 默认进入到当前用户主目录下, 发现除了C:\盘, 可以通过cd .. , cd , dir 去到C:\盘的各个目录外, 不能通过 cd d: 进入到其他盘

可以在c盘各个目录自由切换

不能通过 cd d: 进入到其他盘, 仍停留在原来的位置

有两种方式可以解决这个问题:

cd /d d: 在 cd 和盘符之间加上 /d
e: 不用cd指令 直接用 盘符

https://blog.csdn.net/kakuma_chen/article/details/71173243

How do I add launchable apps into the PDF xchange Editor

Question

I have a PDF I would like to open in a third party PDF application. The Launch Button on the bottom right only has PDF-XChange and Adobe apps by default. Can I add other third party apps?
Solution

The Editor supports the addition of other third party apps to launch PDF directly from it. Many of these applications are auto-detected in the latest versions of the Editor. Please see the steps below to setup custom launch applications.
Adding Custom Launch Application

On the File tab, click Preferences.

The Preferences window will open, locate the Launch Applications category, and click New...

In the following dialog, beside Path, click the folder icon to Browse, then select the program you wish to add.

Choose the correct path and file name to the desired app. For example, the correct default path to PDF-XChange Editor is:

C:\Program Files\Tracker Software\PDF Editor\PDFXEdit.exe

Click OK to complete the task.

You should instantly see the new launch options.

https://www.pdf-xchange.com/knowledgebase/473-How-do-I-add-launchable-apps-into-the-Editor

Wednesday, January 22, 2025

Linux终端清除bash历史命令

 1. 清空当前屏幕内容

clear

2. 清除本次终端历史但下次启动仍留存

history -c

3 彻底清除

nano ~/.bash_profile或nano ~/.bashrc

export HISTSIZE=0

export HISTFILESIZE=0

或者

rm ~/.bash_history