How to read & Print list of Tasks in Task manager window

Class library usage, coding and language questions.
shahnawaz2222
Posts: 4
Joined: Tue Aug 02, 2016 9:29 am

How to read & Print list of Tasks in Task manager window

Post by shahnawaz2222 » Tue Aug 02, 2016 9:36 am

Hi Guys,

I am trying to read the task list dynamically using renorex but i am just getting the first Task as calc getting capured via my script. Not able to capture the list of task and print them using renorex from Task manager window. Please help me . This is bit urgent for me.

Thanks,
Shahnawaz

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: How to read & Print list of Tasks in Task manager window

Post by asdf » Thu Aug 04, 2016 3:23 pm

Hi Shanawaz,

I would use the following code snippet in order to achieve your intention.

Code: Select all

var list = Host.Local.Find<Row>("/form[@name='Task Manager']//container[@automationid='processestab_tables']/table[@automationid='cpuList']/row");
foreach(var item in list)
{
	string proc = item.Element.GetAttributeValueText("Name");
	Report.Info(proc);
}
I hope this helps.

Kind regards,
asdf

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to read & Print list of Tasks in Task manager window

Post by odklizec » Thu Aug 04, 2016 3:43 pm

Hi,

If you don't care about app groups, in which the individual process are grouped (Apps, Background and Windows processes), below xpath returns all available processes as treetiems, where each treeitem represent one running process. To get the name of process use either Text or Name attribute.

Just create a new repo item with below xpath:

Code: Select all

/form[@name='Task Manager']/container/container/container[@automationid='apptab_tables']/container/table/container/treeitem
Then use code like this, to loop though all found treeitems and read Text/Name attribute to get the name of each running process...

Code: Select all

// Create a list of adapters using the "Info" object  
IList<Ranorex.TreeItem> treeItemList =   
    repo.TaskManagerTreeInfo.CreateAdapters<Ranorex.TreeItem>();  
  
// get name of each process and display it in report
foreach (Ranorex.TreeItem treeItemElement in treeItemList )  
{  
    string processNameString= treeItemElement.Text;  
    Report.Info("process Name: " + processNameString);
}  


Hope this helps?

PS: I was not notified there is already a reply in this post, anyway, now you have two similar solutions (with and without repo) ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

shahnawaz2222
Posts: 4
Joined: Tue Aug 02, 2016 9:29 am

Re: How to read & Print list of Tasks in Task manager window

Post by shahnawaz2222 » Wed Aug 10, 2016 11:36 am

Thanks you so much!! I got it now and able to publish the list of Task (count & String) using the code provided by " Asdf" . I am new to Renorex and working on Critical Project POC. if successful , we will be procuring liences.

I also want to know how I can determine the Name of the task under " Application tab of the the task manager" window, Runtime. I mean to say if I open and close an application calc and the sequence of the listing of the application changes, how to determine that or capture this event runtime ?
Please help me.

With Regards,
Shahnawaz

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: How to read & Print list of Tasks in Task manager window

Post by asdf » Tue Aug 16, 2016 8:10 am

Hi shahnawaz,

Since Ranorex is based on SharpDevelop, you can use the whole C# functionality in order to accomplish your intention.

Hopefully, the following links will help you.
How to handle Popups
EventHandler

Sincerely,
asdf