나는 파이썬 응용 프로그램을 개발 중이며 열려있는 각 창을 HWND
개까지 가져오고 싶습니다. 윈도우의 이름과 HWND
이 목록을 필터링하여 특정 윈도우를 관리하고 이동하고 크기를 조정해야합니다.각 창에 HWND 가져 오기?
저는 정보를 찾고자 노력했지만 올바른 코드를 얻지 못했습니다. 나는이 code으로 시도했지만 각각의 창 (그 위대한)의 제목 만 얻었지만 HWND
도 필요합니다. 여기에 오류가
import ctypes
import win32gui
EnumWindows = ctypes.windll.user32.EnumWindows
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
GetWindowText = ctypes.windll.user32.GetWindowTextW
GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
IsWindowVisible = ctypes.windll.user32.IsWindowVisible
titles = []
def foreach_window(hwnd, lParam):
if IsWindowVisible(hwnd):
length = GetWindowTextLength(hwnd)
buff = ctypes.create_unicode_buffer(length + 1)
GetWindowText(hwnd, buff, length + 1)
titles.append((hwnd, buff.value))
return True
EnumWindows(EnumWindowsProc(foreach_window), 0)
for i in range(len(titles)):
print(titles)[i]
win32gui.MoveWindow((titles)[5][0], 0, 0, 760, 500, True)
:
win32gui.MoveWindow((titles)[5][0], 0, 0, 760, 500, True)
TypeError: The object is not a PyHANDLE object
쇼핑 목록과 함께 가고 다른 사람들이 당신을 위해 일할 수있는 슈퍼마켓이 아닙니다. 너 스스로 무엇을 했니? – Difusio
@Difusio : 나는 주변에서 정보를 찾고자 노력했지만 올바른 코드를 얻지 못했습니다. 나는이 http://sjohannes.wordpress.com/2012/03/23/win32-python-getting-all-window-titles/로 해봤지만 각각의 윈도우 (위대한) 제목 만 얻었지만, HWND도. – user1618465
귀하가받은 _errors_ 또는 수행 한 다른 일들과 함께 작성한 _code_ _ _ _을 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 알려주십시오. –