首页 > 移动平台 > 详细

autoJS 网易公开课app封装函数

时间:2020-01-01 13:55:47      阅读:123      评论:0      收藏:0      [点我收藏+]

环境 安卓7.0或以上 网易公开课app

/**
 * 获取用户性别
 * @return str gender 
 */
function getUserGender() {
    if (!requestScreenCapture()) {
        toast("请求截图失败");
        exit();
    }
    waitForActivity("com.netease.vopen.feature.timeline.ui.UserTimelineActivity");
    if (id('timeline_profile_gender').exists()) {
        var rect = id('timeline_profile_gender').findOnce().bounds();
        var img = captureScreen();
        var point = findColor(img, -622207, {
            region: [rect.left, rect.top, rect.width(), rect.height()],
            threshold: 4
        });
        if (point) {
            return "女";
        } else {
            var point = findColor(img, -7943189, {
                region: [rect.left, rect.top, rect.width(), rect.height()],
                threshold: 4
            });
            if (point) {
                return "男";
            }
        };

    } else {
        return "未知";
    }
}
/**
 * 获取用户昵称
 * @return str userName
 */
function getUserName() {
    var userName = '';
    //等待个人人资料页面出现
    waitForActivity("com.netease.vopen.feature.timeline.ui.UserTimelineActivity");
    if (id('mid_title').exists()) {
        userName = id('mid_title').findOnce().text();
    } else {
        log('ERROR:未获取到用户昵称');
    }
    return userName;
}

autoJS 网易公开课app封装函数

原文:https://www.cnblogs.com/qinsilandiao/p/12128723.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!