Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- obs = obslua
- localSettings = settings
- ----------------------------------------------------------
- -- A function named script_properties defines the properties that the user
- -- can change for the entire script module itself
- function script_properties()
- local props = obs.obs_properties_create()
- -- obs.obs_properties_add_path(props, "execPath", "File", obs.OBS_PATH_FILE, "*.exe, *.vbs, *.bat, *.lnk, *.*", nil)
- -- obs.obs_properties_add_text(props, "execList", "List of executables to launch", obs.OBS_TEXT_MULTILINE)
- obs.obs_properties_add_editable_list(props, "execList", "List of executables to launch", obs.OBS_EDITABLE_LIST_TYPE_FILES, "", "")
- obs.obs_properties_add_bool(props, "boolAutoquit", "Autoclose on OBS quit? \n(Only works with .exe)")
- obs.obs_properties_add_button(props, "launchButton", "Launch", launch_func)
- return props
- end
- -- A function named script_description returns the description shown to
- -- the user
- function script_description()
- return "Starts an executable then OBS is started.\n\nV0.4 \n\nMade by Davi Be"
- end
- -- A function named script_defaults will be called to set the default settings
- function script_defaults(settings)
- obs.obs_data_set_default_string(settings, "execPath", "")
- end
- -- A function named script_update will be called when settings are changed
- function script_update(settings)
- end
- -- a function named script_load will be called on startup
- function script_load(settings)
- localSettings = settings
- launch_func()
- end
- -- save additional data not set by user
- function script_save(settings)
- end
- -- function will be called just before OBS quits
- -- quit programm when exiting OBS
- function script_unload()
- -- assemble command
- if obs.obs_data_get_bool(localSettings, "boolAutoquit") then
- for i=0, #execNames do
- cmd = 'taskkill /IM "' .. execNames[i] .. '"'
- -- execute command
- os.execute(cmd)
- end
- end
- end
- function launch_func()
- --execPath = obs.obs_data_get_string(localSettings, "execPath")
- array = obs.obs_data_get_array(localSettings, "execList")
- count = obs.obs_data_array_count(array)
- execNames = {}
- for i = 0, count do
- local item = obs.obs_data_array_item(array, i)
- local itemname = obs.obs_data_get_string(item, "value")
- if(itemname == "") then break
- else do
- execPath = itemname:gsub("/", "\\")
- index = execPath:match'^.*()\\'
- execDir = execPath:sub(1,index)
- execName = execPath:sub(index + 1, execPath:len())
- execNames[i] = execName
- cmd = 'start "" /D "' .. execDir .. '" "' .. execName .. '"'
- os.execute(cmd)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement