Uchwyt okna akurat można łatwo uzyskać, ale pewnie nie do wszystkich programów. Ja akurat korzystam z jakiegoś gotowca z netu:
function ExeProcessToHWnd(ProcessName : string) : HWND;
function EnumProcess(hHwnd : HWND; lParam : integer) : boolean; stdcall;
var
pPid : DWORD;
begin
Result := (hHwnd <> 0);
if Result = True then
begin
GetWindowThreadProcessId(hHwnd, pPid);
if pPid = PidNum then
begin
if (GetWindowLong(hHWND, GWL_HWNDPARENT) = 0)
and (IsWindowVisible(hHWND) or IsIconic(hHWND)) then
begin
AHandle := hHWND;
end;
end;
end;
Result := True;
end;
function ProcessIDFromAppname32(AppName : string) : DWORD;
var
SnapShot : THandle;
processEntry : TProcessEntry32;
begin
Result := 0;
AppName := AnsiUpperCase(AppName);
SnapShot := CreateToolhelp32SnapShot(TH32CS_SNAPPROCESS, 0);
if SnapShot <> 0 then
try
ProcessEntry.dwSize := SizeOf(ProcessEntry);
if Process32First(SnapShot, ProcessEntry) then
repeat
if Pos(AppName, AnsiUpperCase(ExtractFilename
(StrPas(processEntry.szExeFile)))) > 0 then
begin
Result := ProcessEntry.th32ProcessID;
Break;
end;
until not Process32Next(SnapShot, ProcessEntry);
finally
CloseHandle(SnapShot);
end;
end;
begin
PidNum := ProcessIDFromAppname32(ProcessName);
EnumWindows(@EnumProcess, 0);
Result := AHandle;
end;
Można także po "caption" okna