Solved

How do I get a list of the applications in the taskbar?

Posted on 2009-05-15
7
290 Views
Last Modified: 2013-12-03
I wrote a little piece of code in Delphi that retrieves me the list of all the windows running at a time (using EnumWindows).
The problem I have is that seems to list about every little window running, even those inside the applications.
I think I should go other route, since this EnumWindows gets windows, not applications running.

What should I use else?
0
Comment
Question by:fischermx
  • 4
  • 2
7 Comments
 
LVL 13

Expert Comment

by:ThievingSix
Comment Utility
Do you want to get all the processes like the task manager processes tab? If so: http://www.swissdelphicenter.ch/torry/showcode.php?id=616
0
 
LVL 1

Author Comment

by:fischermx
Comment Utility
Nope, I want the applications in the task bar.
0
 
LVL 1

Accepted Solution

by:
KillerCode earned 500 total points
Comment Utility
How-To
 Memo1.Text := ListWindows(1); //Include Inivisble
 Memo1.Text := ListWindows(0); //Don't Include Inivisble

PS : WindowList MUST be a global Variable (Before "Implementation")
var

 WindowList:String;

 

function GetWindowState(Handle: HWND):String;

begin

  If IsWindowVisible(Handle) Then Result := 'Visible'

  Else Result := 'Invisible';

end;

 

function ListWindows(INV:Integer):String;

 

  function EnumWindowProc(Hwnd: HWND; i: integer): boolean; stdcall;

  var

   Titulo : string;

  begin

   if Hwnd <> 0 then

   begin

    SetLength(Titulo, 255);

    SetLength(Titulo, GetWindowText(Hwnd, PChar(Titulo), Length(Titulo)));

    if i = 1 Then if (Titulo<>'') then WindowList := WindowList + GetWindowState(Hwnd) + #9 + Titulo + #9 + IntToStr(Hwnd) + #13#10;

    if I = 0 Then if (IsWindowVisible(Hwnd)) and (Titulo <> '') then WindowList := WindowList + #9 + Titulo + #9 + IntToStr(Hwnd) + #13#10;

   end;

  Result := true;

  end;

begin

 WindowList := '';

 EnumWindows(@EnumWindowProc, Inv);

 Result := WindowList;

end;

Open in new window

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:fischermx
Comment Utility

Great!, The "IsWindowVisible" is what I was looking for.
That did it!! Thank you very much.

Can I ask something more...... how do I get which is the Active window?
I see that in the list of applications filled by EnumWindows the first one seems to be the active one, but I'm not sure if this if I can take this as granted.
0
 
LVL 1

Expert Comment

by:KillerCode
Comment Utility
Easy too, just use GetForegroundWindow and then Get the Text from this handle
function ActiveWindow:string;

var

 Handle: THandle;

 Len: LongInt;

 Title: string;

begin

 Handle := GetForegroundWindow;

 Len := GetWindowTextLength(Handle) + 1;

 SetLength(Title, Len);

 GetWindowText(Handle, PChar(Title), Len);

 ActiveWindow := Trim(Title);

end;

Open in new window

0
 
LVL 1

Author Comment

by:fischermx
Comment Utility
Thank you!!
0
 
LVL 1

Author Closing Comment

by:fischermx
Comment Utility
Thank you!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now