Resource icon

PowerPoint macro for controlling OBS

Delicategenius

New Member
Delicategenius submitted a new resource:

PowerPoint macro for controlling OBS - How to control obs from PowerPoint

I wrote a quick VBA macro that will send keystrokes to OBS tot ell it to change scenes. This way your OBS scenes can change when you move through PowerPoint slides. Means I never have to touch OBS when I’m presenting PowerPoint. Saves me a tonne of work and is kind of simple and awesome.

This is it in action. https://www.linkedin.com/posts/mich...irtualevent-activity-6698929041849880576-luhV

Here’s the macro script

Sub OnSlideShowPageChange()
Dim i...

Read more about this resource...
 

Lawrence_SoCal

Active Member
Intriguing
I've been looking to go the other way (OBS control PPTx page changes) but I think I can adjust work flow to work in the other direction easily enough. I'll just need to update macros as I have way more than 9 scenes (so will need to use 5 digits and an alternate mapping for scenes #10 and higher... or maybe CRTL+# for 0->9 and then CTRL-SHIFT for 10->19 and instead of OBS# using OBSs# to indicate higher ??? ... hmm, have to ponder.). For HoW stream, I'm at around 15+ scenes (under 20)
Thanks for posting
 

yukon92

New Member
Thank you for this code...this was the exact, uncomplicated glue, that I needed for PowerPoint and OBS integration. Simple, easy and very effective.
 

doely

New Member
Argh I can't get this to work for some reason, don't know if anyone can help?

1. I've added the macro and kept the naming the same, saved the presentation as .pptm and enabled macros in the trust centre
2. I have dual monitors so have tried display capture and window capture for PowerPoint Slide Show

I can't work out what piece I'm missing Delicategenius
 

KillerSmurf

New Member
@doely and others

Not Working?
Problem is with the SendKeys command in the script - some type of access violation thing with Windows 10 UAC controller.
  1. RegEdit As Admin
  2. Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  3. Edit the value of EnableLUA and set it to ‘0’
  4. Prompted to Restart = Restart.
  5. Try again = Works
What are consequences of disabling UAC? I don't know.. Probably malware related. but solved it for me.
 

KillerSmurf

New Member
@doely
Update: And you need an ActiveX component on first slide to trigger the Marco. (So put a checkbox or so from developer tab behind something or off screen) - had that in the test above and worked. removed and stopped working, added again and worked.
 

uuoocl

Member
Thanks for sharing this script. Here is another tip to try if it is not working. The script wouldn't work in my Windows 10 dual monitor setup, and adding a "Sleep" function fixed the issue.

Script update

Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub OnSlideShowPageChange()
Dim i As Integer
Dim sNotes As String
Dim sKey As String

i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
s = Left(ActivePresentation.Slides(i).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text, 4)

If Left(s, 3) = "OBS" Then
sKey = "^" & Right(s, 1)
AppActivate ("OBS")
SendKeys (sKey), 1
'pause for the hotkeys
Sleep 100
AppActivate ("PowerPoint")
End If
End Sub
 

xribes

New Member
Thanks for share this script.

It doesn't work in my PC: When I change slide in Powerpoint, I can view scene changes happen in OBS Preview view. But the scenes are not showed automatically in OBS Program View. And Powerpoint window goes under OBS window.

Thanks for your help
 

acbury

New Member
Thanks for the script! I have further improved it so it works on my 64 bit windows 10. I also added in NUMLOCK to be ON because of a bug with VBA macros. VBA macros always seem to turn NUMLOCK OFF when running.

The sleep function definitely helped with my issues @OldFriends


#If VBA7 Then
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If

Sub OnSlideShowPageChange()
Dim i As Integer
Dim sNotes As String
Dim sKey As String

i = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
s = Left(ActivePresentation.Slides(i).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text, 4)

If Left(s, 3) = "OBS" Then
sKey = "^" & Right(s, 1)
AppActivate ("OBS")
SendKeys (sKey), 1
SendKeys "{NUMLOCK}", True
'pause for the hotkeys
Sleep 100
AppActivate ("PowerPoint")
End If
End Sub
 

UroDoc

New Member
I upgraded to OBS 28.01 and this PowerPoint macro no longer works. Previously I had been using it without issue with both numbers and letters for the hotkeys for our church service. When I debug the macro, the line highlighted is: "AppActivate ("OBS"). I tried changing the line to "AppActivate ("OBS Studio") with no results. I also tried AppActivate ("OBS 28.0.1) but this was rejected. I tried that since the title bar is "OBS 28.0.1 (64-bit, windows) - Profile: Church Service - Scenes: Church Service".
Any help would be greatly appreciated. I do not do VB coding.
Thanks
 

Lawrence_SoCal

Active Member
Many OBS plugins require an update to be compatible with the new UI interface in v28
I don't know if this is the issue you are having
 

SteveBailey

New Member
I had the same problem and AppActivate("OBS 28.0.3") worked for me. I didn't need to type in the full text of the title bar, but I needed quote marks on both sides of OBS 28.0.3, where your example only showed a quote at the front end. Also, my application is Python script and not a PowerPoint macro.
 
Top