Get TaskBar Windows

Use this board to post your code snippets - tips and tricks
3 posts Page 1 of 1
Contributors
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Get TaskBar Windows
CodenStuff
Hello,

Because I have released the source-code to AppIconBarv3 which uses the following code I have moved this from the VIP 'First Look' section for general viewing.

Here is a nice easy way to get a complete list off Windows/Applications that are open on the taskbar.

First start a new project or use an existing project and add a "ListBox" control to the form.

Then in code-view add this underneath "Public Class Form..":
Code: Select all
<System.Runtime.InteropServices.DllImport("user32.dll")> _
          Shared Function ShowWindow(ByVal handle As IntPtr, ByVal nCmd As Int32) As Boolean
    End Function

    <System.Runtime.InteropServices.DllImport("user32.dll")> _
    Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As Boolean
    End Function
Then inside the "Form_Load" event or whichever event you wish to use to get the list just add this code:
Code: Select all
For Each TaskPro As Diagnostics.Process In Diagnostics.Process.GetProcesses
            If TaskPro.MainWindowTitle <> Nothing Then
                ListBox1.Items.Add(TaskPro.MainWindowTitle)
            End If
        Next
Change the line that says "ListBox1.Items.Add..." to one of the following to get the required result:

This one will get a list off all windows 'Titles'
Code: Select all
ListBox1.Items.Add(TaskPro.MainWindowTitle)
This one will get a list off all the programs used by the windows (notepad, Paint etc)
Code: Select all
ListBox1.Items.Add(TaskPro.ProcessName)
Thats all there is to it ;)

Happy coding! cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: Get TaskBar Windows
Nery
Hmm, nice... So that was how you added the Show Taskbar Apps in your IconBar ^^
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: Get TaskBar Windows
CodenStuff
Hello,

Yes it is, I added alot more code to it though ;)
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
3 posts Page 1 of 1
Return to “Quick Snips”