Page 1 of 1

Get TaskBar Windows

Posted: Tue Oct 27, 2009 4:26 pm
by 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;

Re: Get TaskBar Windows

Posted: Tue Oct 27, 2009 7:31 pm
by Nery
Hmm, nice... So that was how you added the Show Taskbar Apps in your IconBar ^^

Re: Get TaskBar Windows

Posted: Tue Oct 27, 2009 7:55 pm
by CodenStuff
Hello,

Yes it is, I added alot more code to it though ;)