How to get (and kill) a specific process on an application?

How can I find the specific process name and kill it?

For example, I have this Microsoft application open, and there can be multiple windows open on the application. Let’s say I am working on an open window A on the application.
When the robot tries to close window A like normally (e.g. attach window => close window), and if it fails, I want to just kill that window only, but not the entire application.

I cannot find the process name for that specific window, and I want to know how I can.
As of now, all I can do is, kill the entire application, but that’s not what I want. I want to kill only one specific window on the application, keeping the application itself open.

2 Likes

@Raj222 - Normally Ctrl+w most often used for Close a program …See what is the shortcut key available for that application and use Send Hotkey/keyboard shortcuts.

@Raj222
have a look here:

And here:

getting the PID/TID for the window and matching it to a process / thread was not reliable enough. So we defined the best practice of killing all Processes.

Thank you. The reason why I asked this question was because, sometimes there are so many different types of pop-ups when closing the window. I don’t want to handle each of them because there’s so many. I thought just killing the window itself is the easiest.

Hi,

In simple case, the following might work for you.
(But there are many complicated cases, and this might not work.)

Main.xaml (8.1 KB)

2 Likes

thanks! Unfortunately, this didn’t work in my situation. I tried it, but the condition always failed. But this answer is so far the closest to what I want to achieve.

Hi,

Thank you for trying.
I guess it’s because your target window isn’t Main Window of a process.

Perhaps Win32API GetWindowThreadProcessId will solve your matter. However it’s difficult to call this in default UiPath Studio.

It might work to create custom activity for it in Visual Studio or use the following custom activity, for example.

Regards,