// 先调用EnumChildWindows
{ find the exist game window }
HWndRuningApp := FindWindow(nil, PChar('VCD转换成为MPEG'));
if HWndRuningApp <> 0 then
begin
EnumChildWindows(HWndRuningApp, @CalBack, 0);
SetActiveWindow(HWndRuningApp);
btnFindMpeg.Enabled := True;
btnChoseSaveDir.Enabled := True;
btnVcd2Mpeg.Enabled := True;
end;
// 他会自动调用回到函数的,在此函数中判断你要调用的对象
function CalBack(aa: Hwnd;
bb: LPARAM): Boolean;
stdcall;
var
aClassName, ComponetName: array[0..255] of Char;
begin
Result:=True;
GetClassName(aa, aClassName, 255);
//依次得到子窗体所有控件类名
GetWindowText(aa, ComponetName, 255);
//依次得到子窗体所有控件标题
// ShowMessage(aClassName);
// '(&S)保存MPEG文件'
// '(&L)装入VCD文件'
// '(&S)停止转换'
// '(&B)开始转换'
with FrmMaindo
begin
if (StrComp(ComponetName, PChar('(&B)开始转换')) = 0) and (aa <> 0) then
hwndBtnStart := aa;
if (StrComp(aClassName, PChar('TEdit')) = 0) and (aa <> 0) then
begin
Inc(p_nEditNum);
case p_nEditNum of
1: hwndEdtGetVcd := aa;
2: hwndEdtSaveMpeg := aa;
end;
end;
if (StrComp(aClassName, PChar('TProgressBar')) = 0) and (aa <> 0) then
hwndPrgrsbr := aa;
end;
end;
试试吧,不行再说,毕竟游戏和一般程序不太一样,按钮可能不是标准按钮,而只是整幅图片的一部分