android-wechat-tool icon indicating copy to clipboard operation
android-wechat-tool copied to clipboard

红包页面getRootInActiveWindow为null

Open YummyLau opened this issue 7 years ago • 12 comments

请教下,如题,有什么解决的方案吗

YummyLau avatar Jan 31 '18 07:01 YummyLau

private void getLuckMoney(AccessibilityNodeInfo rootEvent) throws InterruptedException {
    Log.e("test", "收到红包界面----->3");
    AccessibilityNodeInfo rowNode = getRootInActiveWindow();
    if (rowNode == null) {
        Log.e("test", "noteInfo is null");
        Thread.sleep(delayTime);
        performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
        return ;
    }
    Log.e("test", "收到红包界面----->4");
    List<AccessibilityNodeInfo> openList = rowNode.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/c2i");
    rowNode.recycle();
    for (AccessibilityNodeInfo item : openList) {
        Log.e("test",item.getClassName().toString());
        //item.performAction(AccessibilityNodeInfo.ACTION_CLICK);
    }

xml的配置如下: <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" android:accessibilityEventTypes="typeNotificationStateChanged|typeWindowStateChanged|typeWindowContentChanged|typeWindowsChanged" android:accessibilityFeedbackType="feedbackGeneric" android:accessibilityFlags="flagDefault" android:canRetrieveWindowContent="true" android:description="@string/app_name" android:notificationTimeout="100" android:packageNames="com.tencent.mm" />

捕获不到button,点击home键,再次进入微信就能捕获到?这是为何?

YahengWang avatar Feb 06 '18 14:02 YahengWang

我也发现这个问题了,Android 6.0之前版本的手机没问题。在Android 7.0 和 Android 8.1上测试时发现,没当窗口发生改变时getRootInActiveWindow就变成了null,百度+谷歌了半天也没查到解决办法。

sinawangnan7 avatar Apr 17 '18 07:04 sinawangnan7

@sinawangnan7 I have the same problem.In the Activity of "com.tencent.mm.plugin.luckymoney.ui.LuckyMoneyReceiveUI" ,the method of "getRootInActiveWindow()" return null.

NB-Dragon avatar Apr 23 '18 05:04 NB-Dragon

一直试都是获取为空,使用getWindows()方法也是为空,真是无解。

ymxh avatar Jan 25 '19 12:01 ymxh

如果大家还感兴趣,最近用kotlin尝试写了下只支持微信7.0版本的红包插件。后续会继续优化。 https://github.com/YummyLau/KotlinLearn/tree/master/wxrp @YahengWang @sinawangnan7 @NB-Dragon @ymxh

YummyLau avatar Jan 26 '19 09:01 YummyLau

@YummyLau It's OK. I have found an other way to solve it, which you can see the application in NB-Dragon/RedPacketPolice. There is no source code there.

NB-Dragon avatar Jan 26 '19 09:01 NB-Dragon

@NB-Dragon thx!Did it adpter to wechat7.0 ?

YummyLau avatar Jan 26 '19 10:01 YummyLau

@YummyLau Not yet, but it's easy to adapt it if i want.

NB-Dragon avatar Jan 26 '19 10:01 NB-Dragon

如果大家还感兴趣,最近用kotlin尝试写了下只支持微信7.0版本的红包插件。后续会继续优化。 https://github.com/YummyLau/KotlinLearn/tree/master/wxrp @YahengWang @sinawangnan7 @NB-Dragon @ymxh

找不到啦

jp1017 avatar May 28 '19 02:05 jp1017

@YummyLau Not yet, but it's easy to adapt it if i want.

code?

jp1017 avatar May 28 '19 02:05 jp1017

@YummyLau Not yet, but it's easy to adapt it if i want.

code?

I won't give you the code, but i will offer you a tip "dispatchGesture".

NB-Dragon avatar May 28 '19 03:05 NB-Dragon

@jp https://github.com/YummyLau/WechatTools 项目被我迁移到这里了。

YummyLau avatar May 29 '19 06:05 YummyLau