Link to home
Start Free TrialLog in
Avatar of trausti
trausti

asked on

Find All Runnung App ( TWindow.text )

How can i find all running application , windows name
e.g caption of the window of all running application and put it in listbox1?
Avatar of Madshi
Madshi

If you've D4 or D5, you can find all that you need in the free unit "enumStuff.pas", which you can download from my homepage:

http://beam.to/madshi

Regards, Madshi.
Avatar of trausti

ASKER

I get an error on

( function GetWindowList (pid: cardinal = 0; tid: cardinal = 0; onlyThoseInTaskbar: boolean = false) : TWindowList;)

TWindowList; = Error

Get you give me code for button1.click and add all the windows in listbox?
What error do you get?
And which Delphi version do you have?
Avatar of trausti

ASKER

I use Delphi 4, undeclared indentifier
Something like this (not tested):

uses [...], enumStuff;

procedure TForm1.Button1Click(Sender: TObject);
var pl : TProcessList;
    i1 : integer;
begin
  pl := GetProcessList;
  for i1 := 0 to high(pl) do
    listBox1.Add(pl[i1].name);
end;

Regards, Madshi.
Avatar of trausti

ASKER

I want windowname like in macro magic

e.g Untitled - Notepad
Something like this?

procedure TForm1.Button1Click(Sender: TObject);
var pl : TProcessList;
    wl : TWindowList;
    i1 : integer;
begin
  pl := GetProcessList;
  for i1 := 0 to high(pl) do begin
    wl := GetWindowList(pl[i1].pid, 0, true);
    if (wl <> nil) and (wl[0].title <> '') then
         listBox1.Add(wl[0].title)
    else listBox1.Add(pl[i1].name);
end;
Avatar of trausti

ASKER

I get an error on TProcessList,TWindowsList

My Delphi did not understand that class
Have you installed the latest update packs (2 and 3)?
And have you added "enumStuff" to the uses clause of your unit?
You can also simply use EnumWindows and write a callback yourself (See your Win32 API documentation).
Unfortunately, I don't have the code to demonstrate currently...

(P.S: You'll find out there are a whole lot more windows than you think!! ;-)
Avatar of trausti

ASKER

I can't give you answer - mark your comments as answer -
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of trausti

ASKER

I buy hook and sendkeys components from

http://fredsterware.com/delphi.htm

Thanks!!!
Avatar of trausti

ASKER

See ya