obs = obslua

function script_description()
    return "Simulate Hotkey Press"
end

function script_properties()
    local props = obs.obs_properties_create()

    obs.obs_properties_add_text(props, "hotkey_id", "Hotkey ID", obs.OBS_TEXT_DEFAULT)
    obs.obs_properties_add_hotkey(props, "simulated_hotkey", "Simulated Hotkey")

    return props
end

function script_load(settings)
    obs.timer_add(simulate_hotkey_press, 2000)
end

function script_save(settings)
end

function script_unload()
end

function simulate_hotkey_press()
    local hotkey_id = obs.obs_data_get_string(obs.obs_data_create(), "hotkey_id")
    local simulated_hotkey = obs.obs_hotkey_register_frontend("simulated_hotkey", "Simulated Hotkey", hotkey_callback)
    local hotkey_save_array = obs.obs_data_get_array(settings, "simulated_hotkey")
    obs.obs_hotkey_load(simulated_hotkey, hotkey_save_array)
    obs.obs_data_array_release(hotkey_save_array)

    obs.obs_hotkey_trigger(hotkey_id, obs.OBS_HOTKEY_TYPE_TOGGLE)

    obs.obs_hotkey_unregister(simulated_hotkey)
end

function hotkey_callback(pressed)
    if pressed then
        obs.script_log(obs.LOG_INFO, "Simulated hotkey pressed")
    end
end

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: