AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Create Sys Tray / Capture

Ein Thema von Razor · begonnen am 1. Jul 2009 · letzter Beitrag vom 4. Jul 2009
Antwort Antwort
Razor
(Gast)

n/a Beiträge
 
#1

Create Sys Tray / Capture

  Alt 1. Jul 2009, 15:12
Hey!


I was wondering is it possible to get icons and place all of them in a panel or something..
Mad Kernel is supposed to do this but not work with Win7/Vista/X64.

Also Sharp E does it too but it works in 64 bit but theres tooo much code.I only need the tray and taskbar snippet.To test..
  Mit Zitat antworten Zitat
Fridolin Walther

Registriert seit: 11. Mai 2008
Ort: Kühlungsborn
446 Beiträge
 
Delphi 2009 Professional
 
#2

Re: Create Sys Tray / Capture

  Alt 1. Jul 2009, 16:56
The systray is essentially a Toolbar. You can just search for it and get a list of pointer that point to datastructures holding the information about each item inside the systray. You can than read those datastructures using ReadProcessMemory. The whole process is outlined here:

http://www.codeproject.com/KB/applic...lTrayInfo.aspx

This will work for XP and later. Getting the tray icon information for earlier Windows versions is a little bit trickier but doable.

[EDIT: By the way. You can't get all icons correctly because some HICON values are simply invalid. I never found the reason why ... I haven't looked much though as I was only interested on the process IDs associated with the tray icons.]
Fridolin Walther
"While Mr. Kim, by virtue of youth and naiveté, has fallen prey to the inexplicable need for human contact, let me step in and assure you that my research will go on uninterrupted, and that social relationships will continue to baffle and repulse me."
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#3

Re: Create Sys Tray / Capture

  Alt 1. Jul 2009, 17:20
Yes thank you thats what i was LOOKING for!But its possible to get to make the icons interactive i mean left and right mouse button

Zitat:
Supported OS
This application only works on Windows XP. It may run on Windows 2003 too, but since I wasn't sure and since I didn't have the option to test it out, I have a version check and the program exits if it's a non-XP OS. If anyone's interested, they can comment out the version check and run it in on 2003 - but I have no idea as to whether it'll work or not.
Are you sure it works on systems newer than xp for example vista/win 7
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#4

Re: Create Sys Tray / Capture

  Alt 2. Jul 2009, 16:47
Ok i finally managed to do something..I can get Number of tray icons + tooltips however no icons or no mouse interactivity yet.So i hope you guys can help on that one.Ive done my part now i expect from you to do the same.

This works on WINDOWS 7264 RTM Build!

Delphi-Quellcode:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,shellAPI, ComCtrls, ImgList,commctrl, ExtCtrls;

type
  TForm2 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;
    h_Tray:hwnd;

function GetSysTrayWnd: 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 TForm2.Button1Click(Sender: TObject);
var
  h_ico: HICON;
  h_icolist: TStringlist;
  btn_count, i,handleicon: integer;
  h_Process, dwProcessID:DWord;
  Point: Pointer;
  btn_ico: TTBButton;
  nNumberOfBytesRead: dword;
  buffer: array[0..255] of Char;
begin
  h_Tray:=GetSysTrayWnd;
  btn_count:=sendmessage(h_Tray,TB_BUTTONCOUNT,0,0);
  GetWindowThreadProcessId(h_Tray,@dwProcessID);
  h_Process:=OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE,
                        false,
                        dwProcessID);
  point:=VirtualAllocEx(h_Process, nil,
                        4096,
                        MEM_RESERVE or MEM_COMMIT,
                        PAGE_READWRITE);
  for i:=0 to btn_count - 1 do
  begin
    SendMessage(h_Tray, TB_GETBUTTON, i, LPARAM(Point));
    ReadProcessMemory(h_Process,
                      (Point),
                      @btn_ico,
                      sizeof(btn_ico),
                      nNumberOfBytesRead);
    SendMessage(h_Tray, TB_GETBUTTONTEXT , i, LPARAM(Point));
    ReadProcessMemory(h_Process,
                      (Point),
                      @buffer,
                      sizeof(buffer),
                      nNumberOfBytesRead);
    listbox1.Items.Add(buffer);

  end;

  SHOWmessage(inttostr(btn_count));
  handleicon:=SendMessage(h_Tray,TB_GETIMAGELIST,0,0);
  ImageList_GetIcon(handleicon,0,0); ///????
  image1.Canvas.Handle:=ImageList_GetIcon(handleicon,1,0); ///????
Miniaturansicht angehängter Grafiken
untitled_208.png  
  Mit Zitat antworten Zitat
Fridolin Walther

Registriert seit: 11. Mai 2008
Ort: Kühlungsborn
446 Beiträge
 
Delphi 2009 Professional
 
#5

Re: Create Sys Tray / Capture

  Alt 2. Jul 2009, 16:54
Zitat von Razor:
Are you sure it works on systems newer than xp for example vista/win 7
It does work.

Zitat von Razor:
Ok i finally managed to do something..I can get Number of tray icons + tooltips however no icons or no mouse interactivity yet.So i hope you guys can help on that one.
Getting the exact icons is tricky and doesn't work for all icons simply because some HICON values are invalid. To implement interactivity you will have to send the messages that the real systray would send to the application. You can take the parameters from the Tooltip data structure (what message to send and the recipient of the message).

May I ask what are you trying to do? Implement an alternative systray?
Fridolin Walther
"While Mr. Kim, by virtue of youth and naiveté, has fallen prey to the inexplicable need for human contact, let me step in and assure you that my research will go on uninterrupted, and that social relationships will continue to baffle and repulse me."
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#6

Re: Create Sys Tray / Capture

  Alt 2. Jul 2009, 17:50
Shell replacment
  Mit Zitat antworten Zitat
Fridolin Walther

Registriert seit: 11. Mai 2008
Ort: Kühlungsborn
446 Beiträge
 
Delphi 2009 Professional
 
#7

Re: Create Sys Tray / Capture

  Alt 2. Jul 2009, 18:34
Well ... that won't work. I can tell you why:

If you want to build a shell replacement you will replace the shell. Therefore the original shell (Explorer) is not running and the original systray doesn't exist. But you currently read the data from the original systray. You will have to reverse the MSDN-Library durchsuchenShell_NotifyIcon API to find out how exactly the API contacts the systray so you can implement your own one.
Fridolin Walther
"While Mr. Kim, by virtue of youth and naiveté, has fallen prey to the inexplicable need for human contact, let me step in and assure you that my research will go on uninterrupted, and that social relationships will continue to baffle and repulse me."
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#8

Re: Create Sys Tray / Capture

  Alt 2. Jul 2009, 18:52
Why not find out wich processes have tray then findout wich icons they have?

Edit:/ I have found some untis of sharpe enviroment for delphi wich is a shell replacement.It contains the procedures that you said i need.Can you have a look in shell.dproj.
Angehängte Dateien
Dateityp: zip units_162.zip (29,6 KB, 25x aufgerufen)
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#9

Re: Create Sys Tray / Capture

  Alt 2. Jul 2009, 20:22
But for start i will rather make it so i can get icons while explorer is ON.Easier.Any tips?
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#10

Re: Create Sys Tray / Capture

  Alt 4. Jul 2009, 16:56
24hours past still no reply?
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:32 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz