美文网首页
python 通过句柄获取窗口内容

python 通过句柄获取窗口内容

作者: 白菜福 | 来源:发表于2019-10-10 12:18 被阅读0次
# -*- enoding:utf-8 -*-


 # 生成 buffer 对象
import win32con
from win32gui import PyMakeBuffer, SendMessage, PyGetBufferAddressAndLen, PyGetString

length = 10000

# hWnd=68214
hWnd=68302

buf = PyMakeBuffer(length)
length2 = SendMessage(hWnd, win32con.WM_GETTEXT, length, buf)+1
print(length2)
buf = PyMakeBuffer(length2)
print('get: ', SendMessage(hWnd, win32con.WM_GETTEXT, length2, buf))

address, length = PyGetBufferAddressAndLen(buf)
text = PyGetString(address, length)

print('text: ', text)

相关文章

网友评论

      本文标题:python 通过句柄获取窗口内容

      本文链接:https://www.haomeiwen.com/subject/qvvopctx.html