COM通信非常慢(comtypes和MSAA问题!)
我正在尝试编写一个工具来自动安装二进制文件。基本上,我使用 comtypes 和 MSAA 界面与安装窗口交互并驱动安装过程。当弹出一个窗口时,我递归地枚举该窗口上的所有元素,选择最合适的元素(通常是按钮)进行交互,等等。该工具有时运行良好。但有时,枚举元素可能需要很长时间(对于不是很复杂的窗口可能长达 1.5 分钟)。这个问题似乎与时间有关。并不是每时每刻都快乐。我已经在这个问题上坚持了一个星期了。有人可以帮忙吗?请!!!
我能想到的一种可能性是:当我枚举一个窗口时,该窗口被目标应用程序破坏,然后 COM 被破坏并且无法进行进一步的导航。这可能是一个潜在的原因吗?我无法说服自己这一点,因为窗口最终被枚举了。如果枚举过程中窗口消失了,那么窗口元素树的遍历就应该失败,不是吗?
I am trying to write a tool to automatically install a binary. Basically, I use comtypes and MSAA interface to interact with the installation windows and drive the installation procedure. When a window pops up, I recursively enumerate all elements on this window, pick the most appropriate element (typically a button) to interact, and so on. The tool sometimes works fine. But sometimes, it may take very long time in enumerating the elements (could be up to 1.5 mins for a window that is not very complex). And this problem seems to be timing related. It doesn't happy all the time. I have stuck on this problem for a week. Can someone help? Please!!!
One possibility I can think of is: while I am enumerating a window, this window is destroyed by the target application, then COM is mssed up and fails to do further navigation. Could it be a potential reason? I can't convince myself on this because the window is finally enumerated. If the window disappears during the enumeration, the traversal of the window element tree should fail, no?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试对脚本进行分析,直到出现问题,然后查看分析信息以找出额外的时间花费在哪里。
Try profiling the script until the issue occurs, then look through the profiling information to find out where the extra time is being spent.