如何获取通知区域图标的工具提示?

发布于 2024-11-09 20:48:18 字数 87 浏览 0 评论 0原文

我可以用通知区域中的图标枚举应用程序(句柄、pid、路径),并且可以控制图标的位置,但无法获取工具提示。

如何枚举系统托盘图标(包括工具提示)?

I can enumerate the applications (handle,pid,path) with icons in the notification area, and I can control the position of the icons, but I can't get the tooltip.

How can I enumerate systray icons including the tooltips?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

逆光飞翔i 2024-11-16 20:48:18

shell 不提供检查不属于您的程序的通知图标的工具。 (而且它甚至无法枚举属于您的程序的图标;您应该已经知道这些图标。)

我曾经使用过一个劫持部分或全部图标的程序并可选择将它们显示在自己的窗口中,而不是在时钟附近的区域中,因此它必须能够获取所有图标的列表。这是 TraySaver,作者:Mike Lin。如果您想了解他的黑客是如何工作的,可以使用该源代码。

您还可以查看上一个问题的答案,该问题询问有关控制通知区域中的图标

The shell provides no facility for inspecting notification icons that don't belong to your program. (And it provides no way of enumerating even the icons that do belong to your program; you're expected to already know about those.)

I used to use a program that hijacked some or all of the icons and optionally displayed them in its own window instead of in the area near the clock, so it must have been able to get a list of all the icons. It was TraySaver, by Mike Lin. The source is available if you wish to see how his hack worked.

You can also take a look at the answers to a previous question that asked about controlling the position of icons in the notification area.

芸娘子的小脾气 2024-11-16 20:48:18

您应该查看 madshis 组件集合的 madKernal 包。它有一些使用托盘图标的接口。但请注意:

使用 madKernel,您可以管理任何应用程序的托盘图标(请参阅 API“Shell_NotifyIcon”)。这种功能完全没有文档记录,但从 win95 到 winXP 都可以正常工作。

ITrayIcon 界面具有提示、图标、位置等属性。

You should take a look at the madKernal package of madshis component collection. It has some interfaces for working with trayicons. Beware, though:

With madKernel you can manage tray icons (see API "Shell_NotifyIcon") of any application. This kind of functionality is totally undocumented, but works well from win95 to winXP.

The ITrayIcon-interface has properties for hint, icon, position and more.

野鹿林 2024-11-16 20:48:18

这是我在 windows xp 和 delphi 2010 上测试的方法,如果您使用的是不支持 unicode 的 delphi 版本,请确保将读取的字符串转换为 ansi

uses CommCtrl;

function TForm1.GetIconsCount: Integer;
begin
  Result := SendMessage(FindTrayToolbar, TB_BUTTONCOUNT, 0, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    ListTips;
end;

function TForm1.FindTrayToolbar: HWND;
begin
  Result := FindWindow('Shell_TrayWND', nil);
  Result := FindWindowEx(Result, 0, 'TrayNotifyWnd', nil);
  Result := FindWindowEx(Result, 0, 'SysPager', nil);
  Result := FindWindowEx(Result, 0, 'ToolbarWindow32', nil);
end;

procedure TForm1.ListTips;
var
  dwTray: DWORD;
  wndTray: HWND;
  hTray: THandle;
  remoteTray: Pointer;
  tdata: TTBBUTTON;
  i: Integer;
  btsread:DWORD;
  str:Pchar;
begin
  wndTray := FindTrayToolbar;
  GetWindowThreadProcessId(wndTray, @dwTray);
  hTray := OpenProcess(PROCESS_ALL_ACCESS, false, dwTray);
  if hTray <> 0 then
  begin
   remoteTray := VirtualAllocEx(hTray, nil, Sizeof(tdata), MEM_COMMIT,
      PAGE_READWRITE);
    for i := 0 to GetIconsCount - 1 do
    begin
      SendMessage(FindTrayToolbar,TB_GETBUTTON,wparam(i),lparam(remotetray));
      ReadProcessMemory(hTray,remotetray,@tdata,sizeof(tdata),btsread);
      GetMem(str,255);
      ReadProcessMemory(hTray,Ptr(tdata.iString),str,255,btsread);
      ListBox1.Items.Add(str);
      end;
       end
        else ShowMessage('Could not locate tray icons');
    end;
    end.

Here is my method tested with windows xp and delphi 2010 if you are using a version of delphi wich doesn't support unicode make shure you convert the strings read to ansi

uses CommCtrl;

function TForm1.GetIconsCount: Integer;
begin
  Result := SendMessage(FindTrayToolbar, TB_BUTTONCOUNT, 0, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    ListTips;
end;

function TForm1.FindTrayToolbar: HWND;
begin
  Result := FindWindow('Shell_TrayWND', nil);
  Result := FindWindowEx(Result, 0, 'TrayNotifyWnd', nil);
  Result := FindWindowEx(Result, 0, 'SysPager', nil);
  Result := FindWindowEx(Result, 0, 'ToolbarWindow32', nil);
end;

procedure TForm1.ListTips;
var
  dwTray: DWORD;
  wndTray: HWND;
  hTray: THandle;
  remoteTray: Pointer;
  tdata: TTBBUTTON;
  i: Integer;
  btsread:DWORD;
  str:Pchar;
begin
  wndTray := FindTrayToolbar;
  GetWindowThreadProcessId(wndTray, @dwTray);
  hTray := OpenProcess(PROCESS_ALL_ACCESS, false, dwTray);
  if hTray <> 0 then
  begin
   remoteTray := VirtualAllocEx(hTray, nil, Sizeof(tdata), MEM_COMMIT,
      PAGE_READWRITE);
    for i := 0 to GetIconsCount - 1 do
    begin
      SendMessage(FindTrayToolbar,TB_GETBUTTON,wparam(i),lparam(remotetray));
      ReadProcessMemory(hTray,remotetray,@tdata,sizeof(tdata),btsread);
      GetMem(str,255);
      ReadProcessMemory(hTray,Ptr(tdata.iString),str,255,btsread);
      ListBox1.Items.Add(str);
      end;
       end
        else ShowMessage('Could not locate tray icons');
    end;
    end.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文