python根据windows窗体句柄获取进程名和进程线程ID

python根据windows窗体句柄获取进程名和进程线程ID

依赖库:win32 ,psutil
相关参考链接:python库之pywin32
参考代码代码:参考代码
实例代码

from win32 import win32process
import psutil
def test_windows_window():
    app = win32gui.GetWindowText(67526)
    if win32gui.IsWindowVisible(67526) and win32gui.IsWindowEnabled(67526):
        thread_id, process_id = win32process.GetWindowThreadProcessId(67526)
        process = psutil.Process(process_id)
        print(process.name(), process_id)
    proc = psutil.Process(pid=process_id )
    print(proce.name())
    print(app)
相关推荐
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页