网友回复
先看看代码:
# -*- 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)
所使用模块主要是win32gui与win32con
其他窗口操作api
引入模块
import win32gui import win32con import win32api import psutil import win32process
获取当前【鼠标坐标】
# 获取当前鼠标【x y】坐标
point = win32api.GetCursorPos()
通过鼠标坐标 获取鼠标坐标下的【窗口句柄】
# 通过坐标获取坐标下的【窗口句柄】 hwnd = win32gui.WindowFromPoint(x,y) # 请填写 x 和 y 坐标
通过窗口句柄获取 【线程ID 和 进程ID】
# 通过句柄获取【线程ID 进程ID】
hread_id, process_id = win32process.GetWindowThreadProcessId('句柄值')
通过进程ID 获取【进程名称】
# 通过进程ID获取【进程名称】 列:weixin.exe
process = psutil.Process('进程ID').name()
通过进程ID 获取【标准路径】
# 通过进程ID 获取主文件程序【标准路径】 列:D:/filed/windoee/weixin.exe
p_bin = psutil.Process('进程ID').exe()
通过进程ID 获取当前程序的【CPU利用率...
点击查看剩余70%
有没有不依赖embedding向量的RAG技术?
有没有支持实时打断语音通话并后台帮你执行任何的ai模型?
开源ai大模型文件格式GGUF、MLX、Safetensors、 ONNX 有什么区别?
出海挣钱支付收款PayPal、Wise 、PingPong、Stripe如何选择?
如何实现类似google的图片隐形水印添加和识别技术?
linux上如何运行任意windows程序?
ai能写出比黑客还厉害的零日漏洞等攻击工具攻击任意软件系统工程?
js如何获取浏览器的音频上下文指纹、Canvas指纹、WebGL渲染特征?
为啥ai开始抛弃markdown文本,重新偏好html文本了?
网站有没有办法鉴别访问请求是由ai操控chrome-devtools-mcp发出的?


