Sunday, September 20, 2020

Make PowerPoint control other applications

 This will show you the basics (at least right now) of how to use PowerPoint to control other applications.

The basis of this code comes from Michael Kordahi's original post on his Linkedin account and OBS scripts page.  I found this very helpful and wanted to post how to do it, plus possible improvements.

Original post:

And Linkedin Post of an example:

How it works.

The VBA macro, when running in your PowerPoint slide looks at the first entry of the NOTES, parses it, and then sends a keystroke to another program based on the entry.

As you move through slides, it automatically reads it, and if a matching sequence is detected, it will send a command, in this example, to OBS to change camera angles automatically.

So, for example, in a worship situation, perhaps you want certain OBS scenes show be shown based on different powerpoint slides automatically.

Here's how to make it work.

Since this example will allow us to control OBS scenes, were going to use that

1> Create a 3 scenes in OBS

2> Set a hotkey for each one - CTRL+1 for scene1 CTRL+2 for scene2  CTRL+3 for scene3 etc.

3> Make sure that in OBS, when you press CTRL + number the scene changes.  

4> Create or load a powerpoint presentation.


6> in "macro name" call it   OnSlideShowPageChange

Then click on "CREATE"

You'll see this:

Sub OnSlideShowPageChange()

End Sub

7> Make it look like this:

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
AppActivate ("PowerPoint")
End If
End Sub

8> You can "X" out of this and save the change.

9> Now in your presention "NOTES" put OBS1   or  OBS2   or   OBS3  on the first line.  This will correspond to the scenes.

10> Now start your PP presentation (F5) 

11> Make sure that OBS is running with your scenes, and change the slides in powerpoint, you should see the images change in OBS

(in some circumstances, you may need to "RUN" the macro manually to get it going, but normally, if you save the PP as a macro enabled file, when you load it, then you may need to goto

DEVELOPER-> Macro-> select macro and hit RUN

No comments:

Post a Comment