Skip to content

Instantly share code, notes, and snippets.

@fiddyschmitt
Last active November 1, 2022 02:47
Show Gist options
  • Select an option

  • Save fiddyschmitt/7b4fbdcbecc2311b17d6663b2beeda24 to your computer and use it in GitHub Desktop.

Select an option

Save fiddyschmitt/7b4fbdcbecc2311b17d6663b2beeda24 to your computer and use it in GitHub Desktop.
Send hotkey using powershell
[void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
# For some reason, the hotkey has to be sent multiple times
for ($i = 0; $i -lt 10; $i++)
{
#Ctrl + Alt + Shift + s
[System.Windows.Forms.SendKeys]::SendWait("^%+s")
}
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
Register-EngineEvent PowerShell.Exiting -SupportEvent -Action { StopOBSRecording; }
while ($true)
{
Start-Sleep -s 1
}
Function StopOBSRecording()
{
Write-Host "Stopping OBS recording..."
# For some reason, the hotkey has to be sent multiple times
for ($i = 0; $i -lt 10; $i++)
{
#Ctrl + Alt + Shift + S
[System.Windows.Forms.SendKeys]::SendWait("^%+s")
}
Write-Host "Finished."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment