前提・実現したいこと
とあるアプリケーションのテキストボックスをクリック後、クリップボードの値を貼り付けしたい。
発生している問題・エラーメッセージ
親ウィンドウおよび子ウィンドウを取得して、該当の子ウィンドウのハンドルまで判明しています。
しかし、該当の子ウィンドウを選択してクリップボードの値を貼り付けることができません。
助言をお願いいたします。
ソースコード
import ctypes
import array
import pyautogui as gui
import win32gui
hWnd = win32gui.FindWindow("親クラス名",None)
win32gui.ShowWindow(hWnd,1)
win32gui.SetForegroundWindow(hWnd)
BM_CLICK = 0x00F5
def enum_child_windows_proc(handle, list):
list.append(handle)
return 1
if name == "main":
parent_handle = ctypes.windll.user32.FindWindowW("親クラス名", 0)
print(hex(parent_handle))
child_handles = array.array("i") ENUM_CHILD_WINDOWS = ctypes.WINFUNCTYPE( \ ctypes.c_int, \ ctypes.c_int, \ ctypes.py_object) ctypes.windll.user32.EnumChildWindows( \ parent_handle, \ ENUM_CHILD_WINDOWS(enum_child_windows_proc), \ ctypes.py_object(child_handles)) for i in range(len(child_handles)): print(hex(child_handles[i]))
ctypes.windll.user32.SendMessageW(child_handles["列挙した子ハンドルの〇番目"], BM_CLICK, 0, 0)
gui.hotkey('ctrl', 'v')
環境
Windows10
python3.7.4 32bit
あなたの回答
tips
プレビュー