Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6240763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:37:50+00:00 2026-05-24T11:37:50+00:00

I am currently invoking the windows task manager using a click event in WPF.

  • 0

I am currently invoking the windows task manager using a click event in WPF. The event simply executes ‘Process.Start(“taskmgr”).

My question is, is there a way to choose which tab inside task manager is selected when the process starts / is displayed? I am looking to have the ‘performance’ tab selected automatically whenever the click event is raised.

Thanks for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:37:51+00:00Added an answer on May 24, 2026 at 11:37 am

    To expand on Philipp Schmid’s post, I’ve whipped up a little demo:

    Run it as a console application. You need to add references to UIAutomationClient and UIAutomationTypes.

    One possible improvement you (or I, if you desire) can make is to hide the window initially, only showing it after the correct tab has been selected. I’m not sure if that would work, however, as I’m not sure that AutomationElement.FromHandle would be able to find a hidden window.

    Edit: At least on my computer (Windows 7, 32 bit, .Net framework 4.0), the following code initially creates a hidden Task Manager and shows it after the correct tab has been selected. I don’t explicitly show the window after selecting the performance tab, so probably one of the automation lines does as a side-effect.

    using System;
    using System.Diagnostics;
    using System.Windows.Automation;
    
    namespace ConsoleApplication2 {
        class Program {
            static void Main(string[] args) {
                // Kill existing instances
                foreach (Process pOld in Process.GetProcessesByName("taskmgr")) {
                    pOld.Kill();
                }
    
                // Create a new instance
                Process p = new Process();
                p.StartInfo.FileName = "taskmgr";
                p.StartInfo.CreateNoWindow = true;
                p.Start();
    
                Console.WriteLine("Waiting for handle...");
    
                while (p.MainWindowHandle == IntPtr.Zero) ;
    
                AutomationElement aeDesktop = AutomationElement.RootElement;
                AutomationElement aeForm = AutomationElement.FromHandle(p.MainWindowHandle);
                Console.WriteLine("Got handle");
    
                // Get the tabs control
                AutomationElement aeTabs = aeForm.FindFirst(TreeScope.Children,
      new PropertyCondition(AutomationElement.ControlTypeProperty,
        ControlType.Tab));
    
                // Get a collection of tab pages
                AutomationElementCollection aeTabItems = aeTabs.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty,
        ControlType.TabItem));
    
                // Set focus to the performance tab
                AutomationElement aePerformanceTab = aeTabItems[3];
                aePerformanceTab.SetFocus();
            }
        }
    }
    

    Why do I destroy previous instances of Task Manager? When an instance is already open, secondary instances will open but immediately close. My code doesn’t check for this, so the code that finds the window handle will freeze.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently invoking client-side functions and server-side functions from the same button click
Currently, I am developing a product that does fairly intensive calculations using MS SQL
I have a C# windows forms application. The way I currently have it set
I'll start with an example: Apache web server (under Windows) has a nice feature:
Im currently using a java application to run commands on a unix box by
I'm currently learning Java, using a combination of the Head First Java book and
I have a native (windows) application that has an embedded web browser. Currently I'm
Hey, im doing a little app for my smart phone, using Windows Mobile 6.
We are currently using Watin to do UI testing on our web application. In
I'm currently building an application using Sencha Touch. We have a certain Carousel on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.