0

I have created a windows setup application which creates a 'getactivewindow' task in task scheduler and runs under system account which should get the foregroundwindow title of the window which the user currentlyworking with but since 'getactivewindow' is running using system account.

I am not able to capture window title of other users who are logged in.

Note= I cannot run that task with user specific account because of some restriction.

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47

1 Answers1

0
using System.Diagnostics;

public static void Main(string[] args){
   Process[] arrProcesses = Process.GetProcesses();

   foreach (Process p in arrProcesses)
   {
       Console.WriteLine(p.MainWindowTitle);
   }
}

This will get running processes for all users on the local machine. https://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx

mac
  • 485
  • 1
  • 6
  • 29
  • Hi mac thanks for answering, but ho can i get the username using that. I have tried getting the process owner id of explorer.exe but i would like to know wether it is reliable all the time... – ananth reddy May 29 '15 at 11:57
  • Refer to this answer here http://stackoverflow.com/a/777567/2247115. Use that method by passing in p.ProcessName. – mac May 29 '15 at 12:41