想获取旺旺对话子窗口标题,请给个思路。
我用GetWindowText能获得全部窗口标题,但是很多不是旺旺的子窗口。当子窗口打开后会提醒我。请指点,谢谢。
本人是正当用途,没有编virus和malicious code。
我用GetWindowText能获得全部窗口标题,但是很多不是旺旺的子窗口。当子窗口打开后会提醒我。请指点,谢谢。
本人是正当用途,没有编virus和malicious code。
解决方案 »
- 用idhttp登陆139邮箱
- 【ivorytower】男人越成熟越有魅力!
- 连接Access数据库的问题
- 关于adodataset的问题,困扰我一天了,请高手帮忙
- 关于WebBrowser的导航问题
- 浅谈delphi如何增加代码的健壮性
- 当按照书名查询时,系统提示没有该索引:no index with 'bookname' field.何故
- 动态表单的一点小错误---------在线等
- Rxlib中的RxRichEdit如何完全中文化(勿用旧帖回复)!
- 用MEMO怎么来操作第二行,第三行数据呢?虽然有个STRING可是不会用>
- delphi自定义的过程,函数作不作为窗体函数有什么区别?
- 各位老师 救救我呵,我的delphi确程序 编译没有错,但运行出错
procedure TForm1.Timer1Timer(Sender: TObject); //3秒定时
var
hCurrentWindow: LongWord;
szText: array[0..254] of char;
begin
memo1.Clear;
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin //edit1.text是我旺旺的id,旺旺的窗口标题通常 交谈的旺旺id - 我的旺旺id
if GetWindowText(hCurrentWindow, @szText, 255)>0 then
if AnsiEndsStr(Edit1.Text, StrPas(@szText)) and checkbox1.Checked then
begin
Memo1.Lines.Add(StrPas(@szText)); //显示交谈的旺旺id - 我的旺旺id
WinExec('led.exe on 0 4',SW_HIDE); //usb设备上led0 打开4秒,它大于3秒,因此会常亮。
end;
hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;这个code目前可以工作,我担心用AnsiEndsStr会导致误报。我单片机软硬件还好,delphi就差好多了。我通过了解发现旺旺和旺旺打开的进程id都是一样而且是唯一的。因此我想从进程id入手,先找到旺旺进程id然后找和旺旺进程id相同的窗口这样比较妥帖。不晓得说的对不对,请大家给意见。看看需要什么函数。谢谢
再次谢谢回帖的同志。
var
ProcessName: string; //进程名
ProcessID: integer; //进程表示符
i: integer;
ContinueLoop: BOOL;
FSnapshotHandle: THandle; //进程快照句柄
FProcessEntry32: TProcessEntry32; //进程入口的结构体信息
begin
Listbox1.Items.Clear;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); //创建一个进程快照
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32); //得到系统中第一个进程
//循环例举
while ContinueLoop do
begin
ProcessName := FProcessEntry32.szExeFile;
ProcessID := FProcessEntry32.th32ProcessID; //edit2.text 路径 edit1.text 文件名
if AnsiEndsStr(Edit2.Text,ProcessName ) and AnsiEndsStr(Edit1.Text,GetProcessPath(ProcessID)) then
Listbox1.Items.add('应用程序名:' + ProcessName + '#进程ID:' + inttostr(ProcessID) + '路径:' + GetProcessPath(ProcessID));
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
end;
现在可以找到旺旺的进程id啦,可是怎样从进程id 到 所有窗口的标题呢?