I have used AutoHotkey to control Delphi applications. Autohotkey allows you to script most user interactions with a Delphi application. The input can be referenced using position or class names. The important point to remember is that Delphi creates an invisible Main Window to interact with the windows messaging system. This invisible main window is not the main application window. So if you want to interact with the Delphi app user interface it is best to study this application design so you can accomplish your objective.
Take a look at
https://autohotkey.com/board/topic/49125-autohotkey-and-delphi/
"The displayed window of usual Delphi app is not the main window. Typically, the main window is 0x0 sized window with the class name TApplication. And the displayed window is just an owned window of it. So, if you want normal minimize, you should minimize the main window TApplication, not the displayed window. If you think it's cumbersome to do, you may try instead WM_SYSCOMMAND with SC_MINIMIZE to the displayed window, which is supposed to mimic the click on minimize button. "