GInt := 0; hWnd := FindWindow('Shell_TrayWnd', nil); if hWnd <> INVALID_HANDLE_VALUE then begin EnumChildWindows(hWnd, @EnumChildWndProc, 0); iLen := Trunc((GRect.Right - GRect.Left)/GInt); Y := Trunc((GRect.Top + GRect.Bottom)/2); For I := 0 to GInt-1 do begin APoint := Point(GRect.Left + I*iLen-2, Y); Mouse.CursorPos := APoint; Sleep(1000); end; end; function EnumChildWndProc(AhWnd:LongInt; AlParam:lParam):boolean;stdcall; var WndClassName: array[0..254] of Char; begin GetClassName(AhWnd, wndClassName, 254); Inc(GInt); if SameText('TrayNotifyWnd', wndClassName) then GetWindowRect(AhWnd, GRect);
这个有什么api函数吗?
比如说我利用程序杀掉了msn的程序,可是msn的图标还在,如何才能通知托盘,让msn的图标自动消失掉?谢谢~~~
我的思路是这样的
hook杀进程的函数,在杀进程的时候通过进程间通信,向自己的进程发一消息删除托盘。
如果说该杀进程的工具是你写的那就更好办了。
hWnd := FindWindow('Shell_TrayWnd', nil); if hWnd <> INVALID_HANDLE_VALUE then
begin
EnumChildWindows(hWnd, @EnumChildWndProc, 0); iLen := Trunc((GRect.Right - GRect.Left)/GInt);
Y := Trunc((GRect.Top + GRect.Bottom)/2); For I := 0 to GInt-1 do
begin
APoint := Point(GRect.Left + I*iLen-2, Y);
Mouse.CursorPos := APoint;
Sleep(1000);
end;
end;
function EnumChildWndProc(AhWnd:LongInt;
AlParam:lParam):boolean;stdcall;
var
WndClassName: array[0..254] of Char;
begin
GetClassName(AhWnd, wndClassName, 254);
Inc(GInt); if SameText('TrayNotifyWnd', wndClassName) then
GetWindowRect(AhWnd, GRect);
result:=true;
end;
期间还存在一些小的BUG,你自己调试一下吧,就是效果特别的理想,鼠标慢腾腾的。