发帖
充值
 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
首页源码分享c++编写SO供懒人精灵读取屏幕数据插件源码 ...

c++编写SO供懒人精灵读取屏幕数据插件源码

28
回复
20571
查看
[ 复制链接 ]
已绑定手机
已实名认证

108

主题

23

回帖

1万

积分

管理员

积分
16022
2021-8-19 23:28:45 显示全部楼层 阅读模式
采用C++编写SO给懒人调用API



  1. #include <map>
  2. #include <string>
  3. #include <vector>
  4. #include <list>
  5. #include <sys/socket.h>
  6. #include <netinet/in.h>
  7. #include <linux/if.h>
  8. #include <linux/sockios.h>
  9. #include <arpa/inet.h>
  10. #include <semaphore.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <unistd.h>
  15. #include <sys/wait.h>
  16. #include <sys/types.h>
  17. #include <fcntl.h>
  18. #include <android/log.h>
  19. #include <pthread.h>

  20. extern "C"
  21. {
  22.         #include <math.h>
  23.         #include <lua.h>
  24.         #include <lauxlib.h>
  25.         #include <lualib.h>
  26.         #include <lr.h>
  27. };
  28. using namespace std;

  29. void  LOGD(const char* fmt,...){
  30.     char str[4096];
  31.     va_list ap;
  32.     int ret;
  33.     va_start(ap, fmt);
  34.     ret = vsnprintf(str, 4096, fmt, ap);
  35.     if (ret >= 4096)
  36.         return;
  37.     __android_log_print(ANDROID_LOG_DEBUG, "LR", "%s",str);
  38. }

  39. static int lrGetPixel(lua_State *L){
  40.         int ret = 0;
  41.         luaL_checktype(L, 1, LUA_TNUMBER);//参数安全检查
  42.         luaL_checktype(L, 2, LUA_TNUMBER);
  43.         int x = (int)lua_tonumber(L,1);
  44.         int y = (int)lua_tonumber(L,2);
  45.         int w,h;
  46.         int* ptr = (int*)lrGetScreenPixel(0,0,0,0,&w,&h);//获取屏幕数据
  47.         LOGD("ret:%p %d %d",ptr,w,h);
  48.         if(ptr){
  49.                 if(x < w && y < h){
  50.                         uint8_t* argb = (uint8_t*)&ptr[y * w + x];
  51.                         lua_pushinteger(L,argb[0]);
  52.                         lua_pushinteger(L,argb[1]);
  53.                         lua_pushinteger(L,argb[2]);
  54.                         ret = 3;
  55.                 }
  56.                 lrRelease(ptr);//一定要记得释放内存
  57.         }
  58.         return ret;
  59. }


  60. static const struct luaL_Reg R[] = {
  61.     {"lrGetPixel" ,  lrGetPixel},
  62.     {NULL, NULL}
  63. };

  64. extern "C"{
  65.         LR_API int luaopen_liblrapi(lua_State*L)
  66.         {
  67.                 luaL_newlib(L, R);
  68.                 LOGD("load lrapilib");
  69.                  return 1;
  70.         }
  71. }
复制代码



c 读取屏幕数据插件源码.zip

229.76 KB, 阅读权限: 10, 下载次数: 93

售价: 10 金钱  [记录]

使用道具
举报

1

主题

37

回帖

86

积分

注册会员

积分
86
膜拜创始人
回复
使用道具
举报

1

主题

19

回帖

864

积分

高级会员

积分
864
⁶⁶⁶⁶⁶     卧槽⁶⁶⁶⁶⁶⁶    666 ⁶⁶⁶⁶⁶⁶    ⁶⁶⁶⁶⁶⁶     ⁶⁶66⁶⁶⁶⁶     ⁶⁶⁶⁶⁶⁶卧槽    ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶卧槽   ⁶⁶⁶⁶⁶⁶    ⁶⁶66⁶⁶⁶⁶     卧槽⁶⁶⁶⁶⁶⁶     ⁶6666⁶⁶666牛逼!
回复
使用道具
举报

1

主题

23

回帖

39

积分

新手上路

积分
39
牛逼666......
回复
使用道具
举报
已绑定手机

0

主题

28

回帖

199

积分

注册会员

积分
199
这是做什么用的呢
回复
使用道具
举报

2

主题

40

回帖

1041

积分

金牌会员

积分
1041
厉害,顶顶定
回复
使用道具
举报
已绑定手机
已实名认证

14

主题

15

回帖

4018

积分

论坛元老

云控|卡密|云UI|云数据|脚本间通讯

积分
4018
QQ
回复
使用道具
举报

0

主题

31

回帖

84

积分

注册会员

积分
84

膜拜创始人,用做什么滴?
回复
使用道具
举报

1

主题

18

回帖

19

积分

新手上路

积分
19

6666666666666666666666666
回复
使用道具
举报

0

主题

33

回帖

108

积分

注册会员

积分
108

6666666666666666666666666
回复
使用道具
举报
123下一页
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则