Not equal operator in selectors

Hi there,

I’m struggling with the following issue.

In order to cope with pop-ups and such in web applications, I want to close all open windows whose name differ from the target one.

Therefore, I used a close application activity with the following selector "<html title != ‘Target_Window’ >. Is there something wrong with the not equal operator? Any help is highly appreciated.

Thanks in advance,
Nicolò

@ncompa,

Try <> instead of !=.

That does not work either

What if you try with !==(not equal value or not equal type)?

Refer the above Link…

Is a not equal comparison even allowed in selectors? That’s the first time I hear about it (not that we haven’t tried it in the past, but it was never a legit operation).

@ncompa
You could try with a workflow like below:
Main.xaml (7.4 KB)

It finds all top level windows that match the filter (in the example - explorer windows), then iterates over those that do not match the title you want to keep, highlighs and closes the window.

Be careful with CloseApplication with that setup, as it will close the whole application that it will find - that means completely closing explorer in the attached example (which is generally not what you want), hence the CloseWindow was used.

Do note that the .ToArray in the ForEach source is needed to get rid of the IEnumerable context error:

Main has thrown an exception
Source: For each

Message: An ActivityContext can only be accessed within the scope of the function it was passed into.
Object name: 'System.Activities.CodeActivityContext'.

Exception Type: ObjectDisposedException

System.ObjectDisposedException: An ActivityContext can only be accessed within the scope of the function it was passed into.
1 Like

Yeah, you’re right, you cannot use in selectors attribute != value

Thank you for this!!