python 窗体取值 | 您所在的位置:网站首页 › python如何取值 › python 窗体取值 |
我想用Python从另一个程序中读取文本标签.我想我必须使用WM_GETTEXT,但我不知道如何在互联网上找不到任何东西.我的程序获取活动窗口,但不读取文本标签.所以我希望有人可以帮助我. 编辑:我已添加缓冲区和SendMessage部分.我可以从编辑器中获取文本,但不是从我尝试从中获取文本标签的程序. 我有以下代码,我在stackoverflow(Get text from popup window)上找到了这个代码: import win32gui import time while True: window = win32gui.GetForegroundWindow() title = win32gui.GetWindowText(window) if 'GLS Exportdatei' in title: control = win32gui.FindWindowEx(window, 0, 'static', None) buffer = win32gui.PyMakeBuffer(20) length = win32gui.SendMessage(control, win32con.WM_GETTEXT, 20, buffer) result = buffer[:length] print result time.sleep(1) |
CopyRight 2018-2019 实验室设备网 版权所有 |