Ascript 调用蓝牙点击器hid案例

Apk 插件下载地址https://heituwl.lanzn.com/isjDc2dfuh2f以下是全部的案例代码。释放apk文件到手机任意目录,并修改代码里面的路径即可 操作一个蓝牙命令后必须给予500ms以上延迟 fromjava.langimportClass,Integer...

Apk 插件下载地址
https://heituwl.lanzn.com/isjDc2dfuh2f
以下是全部的案例代码。
  释放apk文件到手机任意目录,并修改代码里面的路径即可
   操作一个蓝牙命令后必须给予500ms以上延迟
from java.lang import Class, Integer, Long
from ascript.android.system import R
from ascript.android import plug
import time

context = R.context
# 这里要填实际的路径
clazz_loader = plug.load_apk("/sdcard/bleclickapiv3.apk")
clazz = Class.forName("com.example.bleclickapi.BleApi", True, clazz_loader)
context_class = Class.forName("android.content.Context")
constructor = clazz.getConstructor(context_class)
instance = constructor.newInstance(context)

#不太熟悉as的语法,只提供了一下几个方法能正常调用蓝牙设备,请开发时自行封装下
# 因为蓝牙本身操作就有延时,执行一个蓝牙命令后必须给与500ms以上的延迟,否则接下来的命令会无效
# 请自行把apk文件释放到手机目录的任意位置输入路径即可

# 1.蓝牙设备初始化 传入当前设备的分辨率 这里分辨率传参错会影响后面的点击 只需启动时调用一次即可。
ini_method = clazz.getMethod("ini", Integer.TYPE, Integer.TYPE)
width = 1080
height = 2400
result_ini = ini_method.invoke(instance, Integer(width), Integer(height))
print("ini 调用结果: ", result_ini)

# 2.hid 点击
hid_click_method = clazz.getMethod("hidClick", Integer.TYPE, Integer.TYPE)
# x 和 y 值
x = 50
y = 100
result_hid_click = hid_click_method.invoke(instance, Integer(x), Integer(y))
print("hidClick 调用结果: ", result_hid_click)
time.sleep(1)

# 3.hid 滑动
hid_slide_method = clazz.getMethod("hidSlide", Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE)
# 设置滑动参数的值
x1 = 50
y1 = 100
x2 = 200
y2 = 300
speed = 50
#滑动耗时
result_hid_slide = hid_slide_method.invoke(instance, Integer(x1), Integer(y1), Integer(x2), Integer(y2), Integer(speed))
print("hidSlide 调用结果: ", result_hid_slide)
time.sleep(1+(speed*0.001))

# 4获取蓝牙设备名称
get_bluetooth_name_method = clazz.getMethod("getBluetoothName")
# 调用 getBluetoothName 方法
bluetooth_name = get_bluetooth_name_method.invoke(instance)
print("蓝牙设备名称: ", bluetooth_name)
time.sleep(1)

# 5调用 com_key 方法 ,执行预设的键盘命令
com_key_method = clazz.getMethod("com_key", Integer.TYPE)
# --键盘组合命令
# -- 10=粘贴   vivo手机无效 
# -- 11=最近任务
# -- 12=返回 基本无效 
# -- 13=通知 (大部分手机是回到主屏幕)
# -- 14=主屏幕
# -- 15=显示快捷键
# -- 16=返回 有效 

key_type = 15
# 调用 com_key 方法
result_com_key = com_key_method.invoke(instance, Integer(key_type))
print("com_key 调用结果: ", result_com_key)
time.sleep(1)

# # 读取日志文件
# file = open("/sdcard/ble_api_log.txt", "r+")
# log_content = file.read()
# print("日志内容: ", log_content)
# file.close()

成功案例

image.png


本文来自投稿,不代表蛋果科技立场,如若转载,请注明出处:https://www.3cjc.com/rj/201204.html

阅读 615
上一篇 2024-09-24
下一篇 2024-09-24

相关推荐

  • 懒人精灵调用蓝牙点击器hid案例

    1.首先要下载 apk插件 , 添加到懒人精灵资源中插件下载地址 https://heituwl.lanzn.com/imVv52alkx8f2.准备好我们的蓝牙硬件hid设备,通电连上蓝牙。 蓝牙名称为lydjq-开头的蓝牙名称,后面字母为随机字母3.连接完毕...

    2024-09-24
    752
  • 蓝牙点击器自动化api文档

    各位开发者请注意,请传入正确的数值,错误的数值都会导致蓝牙硬件重启1.使用autojs的开发的作者,可以直接调用sdk文件解压之后,直接运行main.js即可暂时无法在飞书文档外展示此内容2.使用懒人的开发的作者,可以直接...

    2024-09-24
    941
  • EasyClick 调用蓝牙点击器hid案例

    1.首先放入插件插件下载地址 https://heituwl.lanzn.com/imVv52alkx8ffunctionmain(){ //类似这样会先从IEC文件的插件目录查找 loadDex("bleclickapiv3.apk"); varhid=newcom.example.bleclickapi.BleApi(context);...

    2024-09-24
    596
  • ios苹果安卓蓝牙点击器

    ios苹果安卓蓝牙点击器以上线安卓苹果通用 , 支持ios15.6以上系统。

    2024-09-24
    69

发表评论

登录后才能评论

评论列表(128条)

  • 蛋果科技

    2025-09-16~暂无数据~

欢迎来到蛋果科技