# Called program now runs backwards

**URL:** <https://forums.powershell.org/t/called-program-now-runs-backwards/22789>\
**Category:** PowerShell Help\
**Created:** [August 20, 2023, 10:36pm UTC](https://forums.powershell.org/t/called-program-now-runs-backwards/22789 "2023-08-20T22:36:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Gloops](https://avatars.discourse-cdn.com/v4/letter/_/d9b06d/32.png) [@\_Gloops](https://forums.powershell.org/u/_Gloops)\
**Post date:** [August 20, 2023, 10:36pm UTC](https://forums.powershell.org/t/called-program-now-runs-backwards/22789/1 "2023-08-20T22:36:41Z")

</div>

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 :

```auto
Write-Host($l[$nl-1].Name);
&$l[$nl-1].FullName;

```

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 :

```auto
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.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 20, 2023, 11:28pm UTC](https://forums.powershell.org/t/called-program-now-runs-backwards/22789/2 "2023-08-20T23:28:13Z")

</div>

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

> [@\_Gloops](#):
>
> 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.

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

> [@\_Gloops](#):
>
> 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.

According to the their website …

> **[Home · MPC-HC](https://mpc-hc.org/)**
>
> MPC-HC, the free, open source media player for Windows

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

---

<div class="post-metadata">

**Author:** ![\_Gloops](https://avatars.discourse-cdn.com/v4/letter/_/d9b06d/32.png) [@\_Gloops](https://forums.powershell.org/u/_Gloops)\
**Post date:** [August 21, 2023, 12:00am UTC](https://forums.powershell.org/t/called-program-now-runs-backwards/22789/3 "2023-08-21T00:00:04Z")

</div>

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:

```auto
$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 2.0.0.101 of MPC-HC is dated Jul 6th 2023.  
The updater opens automatically to propose an update.

Their website is there:  
[http://www.codecguide.com/](http://www.codecguide.com/)

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

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 21, 2023, 6:54am UTC](https://forums.powershell.org/t/called-program-now-runs-backwards/22789/4 "2023-08-21T06:54:04Z")

</div>

Great that you’ve found a solution. And thanks for sharing. 👍🏼

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:14pm UTC](https://forums.powershell.org/t/called-program-now-runs-backwards/22789/5 "2024-05-16T20:14:43Z")

</div>

Closed on May 16, 2024, 8:14pm UTC


