Called program now runs backwards

Hello everybody,
I wrote a script that lists videos, and allows to select one.
It then displays its name, and opens it with its full path, like this :


It used to run pretty good.

Recently, after I took care of what happens when the list is less than a screen long, OK the video is still opened, but … behind the script window.
I hear the sound, and have to hurry up to click on the window in the tasks bar.
It was so handy to have it above the script window.
I tried a few options for MPC-HC, to show videos “always on top” : by default, always, during playing …
It did not seem to help.
Does anybody have a clue about what happened?

In what I made recently …
As the video is selected with a number, and numbers are typed in capslock, I took care of having the keyboard in capslock when waiting for input, thanks to what somebody proposed on StackOverflow :

if([console]::CapsLock -eq $false){$wsh = New-Object -ComObject WScript.Shell;$wsh.SendKeys('{CAPSLOCK}');$wsh.quit;}

It does not seem that putting this in comments helps, but maybe it is useful to mention.

You may share the complete or at least the relevant part of the code. What you shared looks insufficient.

Does it work as you want it to work when you revert your changes?

According to the their website …

… they stopped developing this software more than 6 Years ago. I’d recommend to switch to something else.

Oh well, sorry I was too quick.
It seems WScript.Shell modified the reaction of the script, and this was the cause of the video played in the background.
But when reading my post again I found a workaround; just after launching the video:

$wsh = New-Object -ComObject WScript.Shell;$wsh.SendKeys('%{ESC}');$wsh.quit;

But the strangest, is that when commenting out this workaround, and letting the call to WScript.Shell to activate CapsLock, well … now everything works fine.
Hum, I am afraid we shall never know what happened really, but I think I should not have found without asking the question.
So, thank you … for your time, if not anything else.

By the way, version of MPC-HC is dated Jul 6th 2023.
The updater opens automatically to propose an update.

Their website is there:

MPC-HC is downloaded with K-Lite codecs pack.

Great that you’ve found a solution. And thanks for sharing. :+1:t3: