Lua script communicating with a browser dock/source?

Mango

Member
Can a Lua script interface with a browser dock or source?

Would like to be able to have a Lua script run a Javascript function in a browser dock. And vice versa.

I was thinking of doing this with websocket and BroadcastCustomMessage but it seems there is no websocket client for lua.

Any other suggestions would be welcome.
 

Mango

Member
I modified the above function I linked to work without a separate get_modifiers function.

Lua:
function hotkey_to_source(source,key,modifiers)
-- Modifiers list (add them to combine)
-- obs.INTERACT_SHIFT_KEY + obs.INTERACT_CONTROL_KEY + obs.INTERACT_ALT_KEY
if type(source) == "string" then source = obs.obs_get_source_by_name(source) end
if string.len(key) == 1 then key = "OBS_KEY_" .. string.upper(key) end
modifiers = modifiers or 0
local event = obs.obs_key_event()
event.native_vkey = obs.obs_key_to_virtual_key(obs.obs_key_from_name(key))
event.modifiers = modifiers
event.native_modifiers = event.modifiers
event.text = "" -- OBS crashes if you don't do this.
obs.obs_source_send_key_click(source,event,true)
end

Examples:
Lua:
hotkey_to_source("BrowserName", "n")
hotkey_to_source("BrowserName", "n", obs.INTERACT_CONTROL_KEY)
hotkey_to_source(obs.obs_get_source_by_name("BrowserName"), "OBS_KEY_N", obs.INTERACT_CONTROL_KEY+obs.INTERACT_ALT_KEY)

Still to figure out: how to use the browser source to trigger Lua code.
 
Top