Click here to Skip to main content
15,884,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WPF application which should find all the running exe's error messages.there is no event logging for running exe's.I tried using automation element and timer but it will not work for multiple processes.is there any other way to implement this ?
Posted
Updated 13-Jan-14 23:38pm
v3
Comments
Mehdi Gholam 14-Jan-14 5:39am    
Your question makes little sense, try explaining more.
Nikhil_S 14-Jan-14 5:56am    
my project is to popup a error window when even there is error in running WPF exe's.so i have used UIAutomationverify and there is a timer running for every 10 seconds interval to check for error window.but this logic will work for only one application at a time and i want this to work for multiple application.is there any way to make this logic work ?
Nikhil_S 14-Jan-14 5:59am    
the reason i used this wierd approach is because there is no event log for the WPF exe's running.I know it's stupidity but i have no other option and very less time.

1 solution

We have to use the Pinvoke GetForegroundWindow method.

IntPtr hwnd = GetForegroundWindow();
            uint pid;
            GetWindowThreadProcessId(hwnd, out pid);
            Process proc = Process.GetProcessById((int)pid);


once we get the processid only for that process i need to run automation element to find error window.and this method for finding active window run every 5 minutes via timer so that if my active window(Process) changes it will work(find error window) for that process.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900