it should still fix some issue Sounds like you need to do a | out-null on the [WhichProcessActive] line of code. It's probably returning the PID as well as setting it in the parameter. PowerShell will send everything down the pipeline so unless you assign a method return value to a variable, or discard it with either [void] or Out-Null, it will also be returned.
This might help you There is an overload of the == operator in which both operands are of type byte and it is implemented to compare the value of each byte; in this case you have two zero bytes, and they are equal. The == operator isn't overloaded for arrays, so the overload having two object operands is used in the second case, and its implementation compares the references to the two objects. The reference to the two arrays are different.
To fix this issue Often, in event handlers, returning false is a way to tell the event to not actually fire. So, for example, in an onsubmit case, this would mean that the form is not submitted. In your example return true; will make the animation occur, while return false; won't.
Return Yes or No instead of True or False in Powershell