Taskbar?

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
16 posts Page 2 of 2
Contributors
User avatar
dj1437
VIP - Donator
VIP - Donator
Posts: 504
Joined: Tue Dec 21, 2010 2:02 am

Re: Taskbar?
dj1437
it would be very hard, there is like 10 errors with like 100 lines in each error, all saying not declared and stuff :P
This is a signature.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Taskbar?
mandai
If you get a warning about System.Windows.Automation not being available then you might need to install the UI Automation package from Microsoft. You will also have to add references to UIAutomationClient and UIAutomationTypes in your project.
User avatar
dj1437
VIP - Donator
VIP - Donator
Posts: 504
Joined: Tue Dec 21, 2010 2:02 am

Re: Taskbar?
dj1437
mandai wrote:
If you get a warning about System.Windows.Automation not being available then you might need to install the UI Automation package from Microsoft. You will also have to add references to UIAutomationClient and UIAutomationTypes in your project.
thanks, it works now, but when i click something nothing happens :( dunnno; dunnno;
This is a signature.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Taskbar?
mandai
What are you trying to click on/what are you trying to do?
User avatar
dj1437
VIP - Donator
VIP - Donator
Posts: 504
Joined: Tue Dec 21, 2010 2:02 am

Re: Taskbar?
dj1437
mandai wrote:
What are you trying to click on/what are you trying to do?
i am trying to click the tasks and nothing happens, and i put a timer so it refreshes every five seconds
This is a signature.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Taskbar?
mandai
Try:
Code: Select all
    Delegate Sub clearItems()
    Sub del_clearItems()
        ListBox1.Items.Clear()
    End Sub

    Delegate Sub addItem(ByVal item As String)
    Sub del_addItem(ByVal item As String)
        ListBox1.Items.Add(item)
    End Sub

    Dim aec As AutomationElementCollection
    Dim collectionIndex As List(Of Integer) = New List(Of Integer)
    Dim taskbar As AutomationElement

    Sub t_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)

        ListBox1.Invoke(New clearItems(AddressOf del_clearItems))
        collectionIndex.Clear()
        
        aec = taskbar.FindAll(TreeScope.Descendants, Condition.TrueCondition)

        Dim adding As Boolean = False
        For i As Integer = 0 To aec.Count - 1
            If aec(i).Current.Name.ToLower() = "running applications" Then 'applications is lower case in win7
                adding = True
                Continue For
            End If

            If adding Then
                collectionIndex.Add(i)
                ListBox1.Invoke(New addItem(AddressOf del_addItem), aec(i).Current.Name)
            End If
        Next
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim taskbarHandle As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
        taskbar = AutomationElement.FromHandle(taskbarHandle)

        Dim t As System.Timers.Timer = New System.Timers.Timer()
        t.Interval = 5000
        AddHandler t.Elapsed, AddressOf t_Elapsed
        t_Elapsed(Nothing, Nothing)
        t.Start()

    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

        If ListBox1.SelectedIndex > -1 Then
            Try
                Dim ip As InvokePattern = aec(collectionIndex(ListBox1.SelectedIndex)).GetCurrentPattern(InvokePattern.Pattern)
                ip.Invoke()
            Catch ex As Exception
                t_Elapsed(Nothing, Nothing)
            End Try

        End If

    End Sub
16 posts Page 2 of 2
Return to “Tutorial Requests”