1
+ # Requires -Version 5.1
2
+ # region Setup Slobs
3
+ function Add-BeardSlobsConnection {
4
+ $npipeClient = New-Object System.IO.Pipes.NamedPipeClientStream($Env: ComputerName , ' slobs' , [System.IO.Pipes.PipeDirection ]::InOut, [System.IO.Pipes.PipeOptions ]::None, [System.Security.Principal.TokenImpersonationLevel ]::Impersonation)
5
+ $npipeClient.Connect ()
6
+ $npipeClient
7
+ }
8
+
9
+ function New-BeardSlobsReader {
10
+ param ($pipeClient )
11
+ New-Object System.IO.StreamReader($pipeClient )
12
+ }
13
+
14
+ function New-BeardSlobsWriter {
15
+ param ($pipeClient )
16
+ New-Object System.IO.StreamWriter($pipeClient )
17
+ }
18
+
19
+
20
+
21
+ function Get-BeardSlobsScene {
22
+ $scenesMessage = ' {"jsonrpc": "2.0","id": 6,"method": "getScenes","params": {"resource": "ScenesService"}}'
23
+ $pipeWriter.WriteLine ($scenesMessage )
24
+ ($pipeReader.ReadLine () | ConvertFrom-Json ).result | Select Name, id
25
+ }
26
+
27
+
28
+
29
+ function Set-BeardSlobsObsScene {
30
+ Param ($SceneName )
31
+ $SceneId = ($scenes | Where Name -eq $SceneName ).id
32
+ $MakeSceneActiveMessage = ' { "jsonrpc": "2.0", "id": 1, "method": "makeSceneActive", "params": { "resource": "ScenesService","args": ["' + $SceneId + ' "]}}'
33
+ $pipeWriter.WriteLine ($MakeSceneActiveMessage )
34
+ $switchResults = $pipeReader.ReadLine () | ConvertFrom-Json
35
+ }
36
+
37
+ # endregion
38
+
39
+ # region Setup PowerPoint
40
+
41
+ function New-BeardSlobsPowerPoint {
42
+ $Application = New-Object - ComObject PowerPoint.Application
43
+ $Application.Visible = ' MsoTrue'
44
+ $Application
45
+ }
46
+
47
+
48
+ function Set-BeardSlobsNextSlide {
49
+ $slideNumber = $PowerPoint.SlideShowWindows [1 ].view.Slide.SlideIndex
50
+ Write-Host " I went to slide $slideNumber "
51
+ $notes = $PowerPoint.SlideShowWindows [1 ].View.Slide.NotesPage.Shapes[2 ].TextFrame.TextRange.Text
52
+ if ($Notes ) {
53
+ Write-Host " The notes are $notes "
54
+ $SceneName = $notes -replace ' OBS:' , ' '
55
+ Write-Host " The scene name is $SceneName "
56
+ Set-BeardSlobsObsScene - SceneName $SceneName
57
+ }
58
+ else {
59
+ Write-Host " There are no notes"
60
+ }
61
+ }
62
+
63
+
64
+ $Client = Add-BeardSlobsConnection
65
+ $pipeReader = New-BeardSlobsReader - pipeClient $Client
66
+ $pipeWriter = New-BeardSlobsWriter - pipeClient $Client
67
+ $pipeWriter.AutoFlush = $true
68
+ $scenes = Get-BeardSlobsScene
69
+ $PowerPoint = New-BeardSlobsPowerPoint
70
+
71
+ $action = { Set-BeardSlobsNextSlide }
72
+ # subscribe to the event generated when the refresh action is completed so we know when to move on to trying to save
73
+ $subscriber = Register-ObjectEvent - InputObject $PowerPoint - EventName SlideShowNextSlide - Action $action
74
+
75
+
76
+
77
+ # endregion
78
+
79
+ $PowerPoint.SlideShowWindows [1 ].View.Slide.NotesPage.Shapes[2 ].TextFrame.TextRange.Text
0 commit comments