0
votes

I need to interact with another application, that resides in the tray. I'm currenty using TestStack White this way:

ProcessStartInfo processStartInfo = new ProcessStartInfo("MyProg.exe");
Application application = Application.AttachOrLaunch(processStartInfo);
_window = application.GetWindows()[0];

Everything works if the application was not running before this call, since launching it, this is visible.

Instead, if the application was already running, and in the tray, White could not find any window, and I can see this in the console as the following log:

Could not find any windows for this application

...and, after some retries, it fails with an exception. Now, the best solution I found is to kill the application and relaunch it:

application.Kill();
application = Application.Launch("MyProg.exe");

and this works. But I guess there is a better solution to this.

2

2 Answers

0
votes

Open the application you want to automate and print all the running process names, find which stands for the application.

The add the following code...

Application myApp;
myApp = Application.Attach("ProcessName");

Hope it helps...

0
votes

Did you try attaching to the explorer.exe process?? Since the system tray icon for the app will reside under the explorer.exe. Something like this:

Did you try attaching to the explorer.exe process?? Since the system tray icon for the app will reside under the explorer.exe. Something like this:

Process _explorerProcess = Process.GetProcessesByName("explorer")[0];
application = Application.Attach(_explorerProcess.Id);
Window desktopWindow = application.GetWindows()[0];

You should then be able to interact with the system tray icon.