# Is there a way to invoke "hotkey" actions from a script or program (Lua, Python, or websockets)?



## John Hartman (Jun 7, 2021)

The "Hotkeys" list under Settings contains many items that would be nice to invoke from a program or script.  Some seem to have API equivalents that can be called from Lua or Python. There are websockets actions for some.

But I don't see any way to invoke others, such as "Next slide" and "Previous slide" for the Slide Show source.

Since hotkeys are discrete actions, it would seem straightforward to have an enumeration or text strings for each item in the hotkey list, and pass that to a function or websockets interface.  (Passing the hotkey itself would be less desirable - there are a LOT of potential actions, it can be a pain to find keys that don't conflict with other program functions)


----------



## Mango (Jun 9, 2021)

You may be interested to know that websockets can do this: https://github.com/Palakis/obs-webs...ocs/generated/protocol.md#triggerhotkeybyname

It would also be super useful to be able to do this from a browser source/dock, without having to install websockets.


----------



## John Hartman (Jun 9, 2021)

Thanks. 
TriggerHotkeyBySequence would let me pass hotkey combination, but as I said above, it would be nice to invoke things without first having to assign a non-conflicting hot key.

TriggerHotkeyByName is what I want - but it needs the "unique name of the hotkey, as defined when registering the hotkey." That is cool for key actions that my script defines, but my current needs are to invoke actions pre-defined by OBS. For example, "Next Slide" and "Previous Slide." Do these have "unique names"? If so, where are they documented?


----------



## Mango (Jun 9, 2021)

I see that the hotkeys for slide shows are not stored with the other hotkeys in %APPDATA%\obs-studio\basic\profiles\[profilename]\basic.ini. Instead they are stored in %APPDATA%\obs-studio\basic\scenes\[scenename].ini.  I created two slide shows for testing purposes and the hotkey names seem to be both called SlideShow.NextSlide.  I don't know how to address a particular slide show.  If you pass SlideShow.NextSlide to TriggerHotkeyByName, I don't suppose that works?

In your position I ended up writing my own slide show script using a browser source.


----------



## John Hartman (Jun 9, 2021)

Nice detective work!
On my PC the \scenes\  information is stored in .json files, but the item names are the same as you indicated.
Time to dig into websockets, I guess.


----------



## thewitt (Jun 10, 2021)

Touch Portal supports this over web sockets so it's definitely possible.


----------



## upgradeQ (Jun 10, 2021)

There is a function `obs_source_media_next(source)` for Slide Show source . You can also inject hotkey events via script like this.
`signal_handler_signal(signal_handler, "media_next", NULL_OR_PARAMS)` - also might help, though it fails for some reason.


----------



## John Hartman (Jun 11, 2021)

Thanks! 
obs_source_media_next doesn't seem to be in the docs at https://obsproject.com/docs/index.html, and Google just finds .h and .cpp files. 
But a quick test in my script shows that it works even from LUA.

I suddenly see myself reading h files to find more goodies.


----------



## TheKiwiviwy (Jul 8, 2021)

Mango said:


> I see that the hotkeys for slide shows are not stored with the other hotkeys in %APPDATA%\obs-studio\basic\profiles\[profilename]\basic.ini. Instead they are stored in %APPDATA%\obs-studio\basic\scenes\[scenename].ini.  I created two slide shows for testing purposes and the hotkey names seem to be both called SlideShow.NextSlide.  I don't know how to address a particular slide show.  If you pass SlideShow.NextSlide to TriggerHotkeyByName, I don't suppose that works?
> 
> In your position I ended up writing my own slide show script using a browser source.


The solution is partially there, after i did some testing i found out the real answer on how to make it work.
While the documentation implies that you need to put the name of the scene and then the hotkey as there for the example of: Replaybuffer.Save

The actual answer for me was: ( This example was done using NOOBS CMDR )
/command=TriggerHotkeyByName,hotkeyName=fast_forward

I didn't had to put the name of the scene, and the fast_forward section was the name that i found on the .json files ( located in %APPDATA%\obs-studio\basic\scenes\ )

so in short, just look up the hotkey name in the .json files and that should be the input that needs to go after the hotkeyName=


----------



## untoldent (Oct 11, 2022)

OBS Extended Touch Portal user here. The hotkey names are SlideShow.PreviousSlide and SlideShow.NextSlide.
But those seem generic? What happens if i have multiple slideshows, and i want to trigger a hotkey that advances one, but not the other?


----------

