2022-09-17

python获取子窗口句柄

python获取窗口句柄

python获取进程

python获取电脑微信小游戏的窗口句柄

上图为按键精灵的工具

python3,简单的获取了下句柄,想改改内存的,后面没什么进展就中止了

import win32gui
import win32process
window_handle = win32gui.FindWindow(None, '羊了个羊')
print('主窗口', window_handle)
process_id = win32process.GetWindowThreadProcessId(window_handle)
print('主窗口的进程', process_id, hex(process_id[0]), hex(process_id[1]))

hWnd_child_list = []
win32gui.EnumChildWindows(window_handle, lambda hWnd, param: param.append(hWnd), hWnd_child_list)
print('子窗口 ID', hWnd_child_list)

process_id01 = win32process.GetWindowThreadProcessId(hWnd_child_list[0])
print(process_id01, 'zi0', hex(process_id01[0]), hex(process_id01[1]))

process_id01 = win32process.GetWindowThreadProcessId(hWnd_child_list[1])
print(process_id01, 'zi1', hex(process_id01[0]), hex(process_id01[1]))

 

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐