Windows アプリケーションのユーザー シナリオを記録したいと考えています。このために、画面キャプチャとマウス位置の横にあるオブジェクトをマウスでクリックした後、GUI オブジェクトのオブジェクト タイプ、オブジェクト名、およびオブジェクト値を取得/ログに記録したいと考えています。
私はハウツーを見つけることに行き詰まっています。助けてください。
次のPythonコードがあります。
saveDir = r'C:\Privat\ZuppU\temp'
stepListID = 1
def capture_step_objects(event):
global stepListID
stepEvent = 'Click'
# Capture the application mouseclick area
(mx, my) = event.Position
fgWindow = win32gui.GetForegroundWindow()
fgWindowName = win32gui.GetWindowText(fgWindow)
# Capture the application window
(ax1, ay1, ax2, ay2) = win32gui.GetWindowRect(fgWindow)
stepCapture = ImageGrab.grab((ax1, ay1, ax2, ay2))
stepImage = os.path.join(saveDir, 'Step' + str(stepListID) + '.png')
stepCapture.save(stepImage)
hm = pyHook.HookManager()
hm.SubscribeMouseAllButtonsDown(capture_step_objects)
hm.HookMouse()
pythoncom.PumpMessages()
hm.UnhookMouse()
# Main loop