Send hotkeys to OBS from PowerPoint

Non-OBS Script Send hotkeys to OBS from PowerPoint

This script is similar to PowerPoint macro for controlling OBS. They both send hotkeys from PowerPoint to OBS.
The difference here is the hotkey commands are stored in the section name.
For Example a section name is set to 'hotkey=%{F5}" (Alt + F5). When a slide in this section is displayed "Alt+F5" is sent to OBS. Having PowerPoint handle scene transitions can be useful for live presentations.

This is a Video Guide to configure PowerPoint to send hotkeys to OBS

To Use this script
  1. Set Hotkeys in OBS
  2. Set PowerPoint section names
  3. add the macro to PowerPoint
    1. Alt+F11 to open VBA editor
    2. Insert-->Module
  4. Save PowerPoint as macro-enabled .PPTM
Script
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub OBSHotKeys(Keys As String)
    AppActivate "OBS ", True
    SendKeys Keys, True

    'pause for the hotkeys to arrive
    Sleep 100

    'AppActivate "PowerPoint Slide Show "
    AppActivate "PowerPoint"
End Sub

Sub OnSlideShowPageChange()
    Dim Slide_ID As Integer
    Dim Section_ID As Integer
    Dim Section_Name As String
    
    'get current slide number
    Slide_ID = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
    
    'get Section index
    Section_ID = ActivePresentation.Slides(Slide_ID).sectionIndex

    'get Section name
    Section_Name = ActivePresentation.SectionProperties.Name(Section_ID)

    'if section starts with "hotkey="
    If Left(Section_Name, 7) = "hotkey=" Then
        OBSHotKeys (Mid(Section_Name, 8))
    End If
    
End Sub

This has been tested in Windows 10, OBS 26 and PowerPoint 365.

The key code table can be found here.
https://docs.microsoft.com/en-us/office/vba/api/excel.application.sendkeys
  • Like
Reactions: taoza
Author
uuoocl
Views
6,244
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from uuoocl

Latest reviews

That's great, thanks man! This is exactly what I was looking for. I now can setup my whole presentation in PPT and switch scenes when changing PPT slides. Combined with green screen behind me and green areas/slides in the presentation I have completely changed OBS scene setup simply by changing PPT slides with a remote. Simple, yet awesome.

Tip for users: PPT sends the trigger to OBS after animations. So just put a copy of the slide without animations in front of the slide with animations and use it just for OBS control, automatic move to next slide after 0.1 sec or so.
Top