Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于模拟器前台的一些个人经验 #7

Closed
zyhazwraith opened this issue Apr 26, 2022 · 3 comments
Closed

关于模拟器前台的一些个人经验 #7

zyhazwraith opened this issue Apr 26, 2022 · 3 comments

Comments

@zyhazwraith
Copy link

zyhazwraith commented Apr 26, 2022

经测试在雷电模拟器下是可以的,只需要添加一行代码,可以移步最后面。

可以用spy++查看,模拟器最顶端是一个模拟器的窗口,然后还有subwindow,

例如雷电模拟器,

窗口名字:
雷电模拟器
TheRender
sub

获取到这个TheRender的handle给handle_num即可

另外,木木模拟器实测无法完成点击,有可能是对后台模拟操作进行了屏蔽。

自用偷懒的改法,

diff --git a/modules/ModuleHandleSet.py b/modules/ModuleHandleSet.py
index 73f1856..4c00ba9 100644
--- a/modules/ModuleHandleSet.py
+++ b/modules/ModuleHandleSet.py
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+import win32gui
 from os.path import abspath, dirname
 from win32api import OpenProcess
 from win32con import PROCESS_ALL_ACCESS
@@ -20,6 +21,8 @@ class HandleSet:
     def get_handle_num(self):
         """通过句柄标题获取句柄编号"""
         self.handle_num = FindWindow(None, self.handle_title)  # 搜索句柄标题,获取句柄编号
+        self.handle_num = win32gui.FindWindowEx(self.handle_num, 0, None, "TheRender")
+        print("adjust handle to", self.handle_num)
         if self.handle_num == 0:
             print("目标程序未启动,即将中止!")
             return None  # 返回异常
@aicezam
Copy link
Owner

aicezam commented Apr 26, 2022

感谢提供思路,看了下这种方法针对性比较强,前提是要知道子句柄的标题,我电脑上装了Hyper-V,没法按模拟器不想调试,改天装上吧,我也先弄个偷懒的兼容方法,改天把其他模拟器慢慢加上哈哈哈哈~

def get_handle_num(self):
        """通过句柄标题获取句柄编号"""
        self.handle_num = FindWindow(None, self.handle_title)  # 搜索句柄标题,获取句柄编号
+       if self.handle_title == "雷电模拟器":
+           self.handle_num = FindWindowEx(self.handle_num, 0, None, "TheRender")  # 兼容雷电模拟器后台点击
+       else:
            if self.handle_num == 0:
                print("目标程序未启动,即将中止!")
                return None  # 返回异常
            else:
                return self.handle_num

@zyhazwraith
Copy link
Author

我试了木木雷电夜神,都是这样的结构,找到模拟器的第一个子句柄就行。当然木木点击无效。

@aicezam
Copy link
Owner

aicezam commented Apr 27, 2022

模拟器的后台兼容我还是想用adb的方式来解决
https://blog.csdn.net/L_fly_J/article/details/110948248

@aicezam aicezam closed this as completed Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants