网友回复
先看看代码:
# -*- 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%
如何让ai帮我自动在小红书或抖音上自动根据需求截流与潜在客户聊天拉客?
如果用go编写一个在virtualbox中启动的简单操作系统?
go如何搭建一个零信任网络?
如何用python实现一个公网代理访问软件?
如何用go实现一个公网代理访问软件?
如何用python实现一个内网穿透打洞程序,实现内网的80端口暴露到公网上可以访问?
如何用go实现一个内网穿透打洞程序,实现内网的80端口暴露到公网上可以访问?
何为Shadowsocks 代理?
python如何实现类似php的opendir目录相互隔离的fastcgi多租户虚拟空间?
nodejs如何实现类似php的opendir目录相互隔离的fastcgi多租户虚拟空间?


