StartAutomating / obs-powershell

Script OBS with PowerShell
https://obs-powershell.start-automating.com
MIT License
50 stars 4 forks source link

Cannot get the package to work #140

Closed kevinagius closed 1 year ago

kevinagius commented 1 year ago

I have just upgraded to PowerShell 7 to run this package however when I run the following Install-Module obs-powershell -Scope CurrentUser -Force to install it I am getting this error.

WARNING: The version '2.0.3' of module 'ThreadJob' is currently in use. Retry the operation after closing the applications.

I have closed everything, restarted my PC and this above error is still showing up.

Running Import-Module obs-powershell -PassThru -Force seems to be functioning properly

However Connect-OBS -WebSocketToken $myToken yields a "Cannot index into a null array" error

I run Get-OBSHotKey command it show me a MethodInvocationException: C:\Users\kevin\Documents\Powershell\Modules\obs-powershell\0.1.9\Commands\Send-OBS.ps1:151 with further details of Exception calling "SendAsync" with "4" argument(s): "Cannot access a disposed object. Object name: 'System.Net.WebSockets.ClientWebSocket'."

Can someone please help me with installing this package as it would help me immensely and I have been stuck on this for days now and I have searched multiple forums but I can't find anything

kevinagius commented 1 year ago

@nyanhp @I-Am-Jakoby @StartAutomating

kevinagius commented 1 year ago

If you could also help me with making a Powershell script which sends the Hotkey for Key number 2 to OBS I would truly appreciate it.

StartAutomating commented 1 year ago

@kevinagius this sounds like ThreadJob's problem.

I wonder if you have an old copy of ThreadJob.

Alternatively, I can think of a couple of other possibilities:

  1. You could be running an older copy of obs (perhaps with the websocket disabled)
  2. The password to the websocket might be wrong (which would auto close the web socket, thus giving you that "disposed" object error).

There's also a slightly known annoyance of getting an indexing error upon the very first connection (an issue needs to be filed for it, and, if you're falling into that rabbit hole, this would be it).

It's especially annoying because it just displays the error and then works just fine after the first command (of the very first connection).

So, let's try a few things:

  1. Update-Module ThreadJob -Force (just in case)
  2. Share your $psVersionTable (just in case)
  3. Connect-OBS with a token directly copied / pasted from the field. If you used a different port, you may need to also provide a URI to localhost.
  4. Double check to see if commands work, despite the error.
  5. If they do, import the module again and confirm there is no error.
kevinagius commented 1 year ago

@StartAutomating

I have reinstalled ThreadJob (for reference to anyone experiencing this issue: https://stackoverflow.com/questions/66305351/powershell-unable-to-update-powershellget-error-the-version-1-4-7-of-modul) and now the commandInstall-Module obs-powershell -Scope CurrentUser -Force gave me no errors as well as the Import-Module command: image

Connect-Obs -WebSocketToken '' seemed to work also image

But the Get-OBSHotkey command is still giving me the same issue. Maybe it is my usage? image

The sole purpose of this project is basically I have a hotkey set to NUMPADSUB and NUMPADMULT which allow me to start and stop recording. In addition I have a powershell script to compress archives which allows me to compress my videos. I would like to create a Task Scheduler event to run the script every hour or so. In the script I would like to initially have it sending the NUMPADSUB hotkey to stop recording, go through the compress archive script which I have written and then send NUMPADMULT to OBS to restart recording.

$psVersionTable output: image

StartAutomating commented 1 year ago

Can you assign Connect-OBS to a variable, and then pipe it to Receive-Job -Keep?

Get-OBSHotKey is working for me.

My best guess is something wrong during connection.

kevinagius commented 1 year ago

Just got a connection: image

And I can see it successfully on OBS: image

I will be trying to send hotkeys now. I will keep you updated

kevinagius commented 1 year ago

Unbelievable! I managed to get it to work! image

Recording started and stopped as required. You have no idea how happy I am. I am very grateful for your help and support, and I truly appreciate your work. You have made my life a million times easier.

Issue closed!!