Skip to content

PowerPoint VBA 'SendKeys' no longer working #12594

@dwh25nz

Description

@dwh25nz

Operating System Info

Windows 11

Other OS

No response

OBS Studio Version

31.1.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/EZqXX8QN2oDvtmfP

OBS Studio Crash Log URL

No response

Expected Behavior

For a number of years I have used Microsoft Visual Basic for Applications in PowerPoint to control OBS Studio, i.e. a change of slide in PowerPoint uses 'SendKeys' to mimic a hotkey in OBS Studio and switch to a different scene. This worked up to OBS version 30.2.3 but sometime after that an update broke this functionality and newer versions of OBS no longer respond to the 'SendKeys' instruction. I'm not sure which version update broke this functionality but it basically means I am stuck at version 30.2.3 until the issue can be resolved. (Attached log file is of this working with version 30.2.3)

2025-09-06 13-58-59.txt

Current Behavior

PowerPoint 'SendKeys' didn't work to trigger the hotkeys. (Attached log file is of this not working with version 31.1.2 - uses the same powerpoint slideshow as above)

2025-09-06 13-51-34.txt

Steps to Reproduce

  1. when triggered by particular slide changes Powerpoint uses VB to switch focus to OBS (this works)
  2. a SendKeys hotkey is sent to switch scenes in OBS (this is broken in versions after 30.2.3)
  3. The VB script shifts focus back to the Powerpoint slideshow (this works)
    ...

Anything else we should know?

Here's the VB I'm using:

#If Win64 Then
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#Else
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
Private Declare PtrSafe Function WaitMessage Lib "user32" () As Long
Option Base 1
Const offering As Integer = 15 'populate with offering slide number
Const catechism As Integer = 99 'populate with catechism slide number (or 99 if no catechism)
Const covenantstart As Integer = 99 'populate with first covenant slide number (or 99 if no covenant)
Const covenantend As Integer = 99 'populate with last covenant slide number (or 99 if no covenant)
Const finalslide As Integer = 76 'populate with the last visible slide number
Dim songstart(6) As Integer
Dim songend(6) As Integer

Sub AssignSongs()

songstart(1) = 4      'populate with first slide number of each song (DUPLICATE FIRST SLIDE in PP)
  songend(1) = 6      'populate with the last slide number of each song

songstart(2) = 10
  songend(2) = 13
  
songstart(3) = 28
  songend(3) = 30

songstart(4) = 37
  songend(4) = 41

songstart(5) = 57
  songend(5) = 64

songstart(6) = 67
  songend(6) = 73

End Sub

Sub initiatePP()
ShowOBSisListening
ActivePresentation.SlideShowWindow.View.Next
ShowCamera
PauseProcess 5
ShowPP
AssignSongs
End Sub

Sub OnSlideShowPageChange()
Dim currentSlide As Integer
currentSlide = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
If currentSlide = 3 Then
ShowCamera
StartStream
PauseProcess
StartStream
Exit Sub
ElseIf currentSlide = offering Then
ShowPPoffering
Exit Sub
ElseIf currentSlide = catechism Then
ShowPPcatechism
Exit Sub
ElseIf (currentSlide = offering + 1) Or (currentSlide = catechism + 1) Then
ShowCamera
Exit Sub
ElseIf currentSlide = finalslide Then
ShowOutro
Exit Sub
ElseIf currentSlide = covenantstart Then
ShowPPintro
Exit Sub
ElseIf currentSlide = covenantend + 1 Then
ShowCamera
Exit Sub
End If
Dim songnumber As Integer
For songnumber = 1 To 6
If currentSlide = songstart(songnumber) Then
ShowPPintro
Exit Sub
ElseIf currentSlide = songstart(songnumber) + 1 Then
ShowPPsong
Exit Sub
ElseIf currentSlide = songend(3) + 1 Then
ReadySermon
Exit Sub
ElseIf currentSlide = songend(songnumber) + 1 Then
ShowCamera
Exit Sub
End If
Next songnumber
End Sub

Sub ShowPP()
AppActivate "OBS"
PauseProcess
SendKeys "^{6}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub ShowPPintro()
AppActivate "OBS"
PauseProcess
SendKeys "^{2}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub ShowPPsong()
AppActivate "OBS"
PauseProcess
SendKeys "^{3}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub ShowPPoffering()
AppActivate "OBS"
PauseProcess
SendKeys "^{4}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub ShowPPcatechism()
AppActivate "OBS"
PauseProcess
SendKeys "^{5}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub ShowCamera()
AppActivate "OBS"
PauseProcess
SendKeys "^{1}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub ReadySermon()
AppActivate "OBS"
PauseProcess
SendKeys "^{0}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub ShowOutro()
AppActivate "OBS"
PauseProcess
SendKeys "^{7}"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub StartStream()
AppActivate "OBS"
PauseProcess
SendKeys "+{RIGHT}"
PauseProcess 1
SendKeys "+{RIGHT}"
PauseProcess 2
AppActivate "PowerPoint Slide Show"
End Sub

Sub ShowOBSisListening()
AppActivate "OBS"
PauseProcess
AppActivate "PowerPoint Slide Show"
End Sub

Sub PauseProcess(Optional pausetime)
If IsMissing(pausetime) Then
pausetime = 0.1
End If
Sleep pausetime * 1000
End Sub

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions