问:关于使用一个程序控制另一个程序界面的问题
想做一个程序A,来控制另外一个界面界面B的界面操作,程序B是一个基于对话框的
但再做的时候遇到了一个问题:程序B的界面是用Delphi做的,我遍历其窗口控件时只能遍历到如下控件:TSpeedBar,TGroupBox等控件
却不能遍历到其相应的Button,Edit等一类的vc控件,但对Delphi控件的控制再vc中似乎没有方法的啊
不知道再如何向下做了,高手指点一下,不胜感激
问题点数:40、回复次数:8Top
1 楼Snow_Ice11111(雪上加冰)回复于 2006-05-03 22:29:24 得分 0
枚举程序B中各控件,然后根据自己的要求SendMessage来按下按钮或发送字符串都随你了,至不济,你还可以用mouse_event来模拟鼠标操作。Top
2 楼eminwoo(天邪鬼)回复于 2006-05-04 08:12:25 得分 0
用Spy++找一下 应该可以找到的Top
3 楼C200501111(cv)回复于 2006-05-04 12:34:26 得分 0
还有更好的建议吗?楼上的两位方法我都尝试了啊
我所疑惑的是我遍历到是delphi控件,而非vc控件啊,所以无法用vc去操作到,不知道有其它方法没有?Top
4 楼C200501111(cv)回复于 2006-05-04 18:19:16 得分 0
现在我拿到了ToolbarWindow32工具条的句柄,如何遍历其上边的按钮呢Top
5 楼Wen_Wen_Zi()回复于 2006-05-04 21:09:53 得分 0
万般皆下品, 唯有VC高!Top
6 楼C200501111(cv)回复于 2006-05-16 15:46:38 得分 0
upTop
7 楼jiayodo(爱上一只猪)回复于 2006-07-09 15:17:15 得分 0
sendmessage(handle, TB_GETBUTTON, ...)Top
8 楼jiayodo(爱上一只猪)回复于 2006-07-09 15:18:54 得分 0
void CTrayDlg::OnButton1()
{
// TODO: Add your control notification handler code here
HWND wd=::FindWindow("Shell_TrayWnd",NULL);
if (wd==NULL)
{
MessageBox("Error1");
return;
}
HWND wtd=FindWindowEx(wd,NULL,"TrayNotifyWnd",NULL);
if (wtd==NULL)
{
MessageBox("Error2");
return;
}
HWND wd1=FindWindowEx(wtd,NULL,"ToolbarWindow32",NULL);
if (wd1==NULL)
{
MessageBox("Error3");
return;
}
DWORD pid;
pid=0;
GetWindowThreadProcessId(wd1,&pid);
if (pid==NULL)
{
MessageBox("Error4");
return;
}
HANDLE hd=OpenProcess(PROCESS_QUERY_INFORMATION ¦ PROCESS_ALL_ACCESS ,true,pid);
if (hd==NULL)
{
MessageBox("Error6");
return;
}
int num=::SendMessage(wd1,TB_BUTTONCOUNT ,NULL,NULL);
int i;
unsigned long n;
TBBUTTON p,*pp;
CString x;
wchar_t name[256];
unsigned long whd,proid;
CString temp;
TBBUTTON *sp;
sp= (TBBUTTON *)0x20f00;
for(i=0;i<num;i++)
{
::SendMessage(wd1,TB_GETBUTTON,i,(LPARAM)sp);
pp=&p;
ReadProcessMemory(hd,sp,pp,sizeof(p),&n);
// x.Format("%x %x %x %x %x %x",p.iBitmap,p.idCommand,p.fsState,p.fsStyle, p.dwData, p.iString);
name[0]=0;
if (p.iString!=0xffffffff)
{
try
{
ReadProcessMemory(hd,(void *)p.iString,name,255,&n);
name[n]=0;
}
catch(...)
{
}
// x+=" ";
// x+=name;
temp=name;
try
{
whd=0;
ReadProcessMemory(hd,(void *)p.dwData,&whd,4,&n);
}
catch(...)
{
}
proid=0;
GetWindowThreadProcessId((HWND)whd,&proid);
x.Format("位置=%d 名称=%s 窗口句柄=%08x 进程ID=%08x",
i,(LPCTSTR )temp,whd,proid);
m_list.AddString(x);
}
}
}
Top




