Advertisement
Guest User

OBS Autostarter multiple programs at once edit

a guest
May 18th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. obs           = obslua
  2.  
  3. localSettings = settings
  4. ----------------------------------------------------------
  5.  
  6. -- A function named script_properties defines the properties that the user
  7. -- can change for the entire script module itself
  8. function script_properties()
  9.  
  10.     local props = obs.obs_properties_create()
  11.    
  12.     -- obs.obs_properties_add_path(props, "execPath", "File", obs.OBS_PATH_FILE, "*.exe, *.vbs, *.bat, *.lnk, *.*", nil)
  13.  
  14.     -- obs.obs_properties_add_text(props, "execList", "List of executables to launch", obs.OBS_TEXT_MULTILINE)
  15.  
  16.     obs.obs_properties_add_editable_list(props, "execList", "List of executables to launch", obs.OBS_EDITABLE_LIST_TYPE_FILES, "", "")
  17.  
  18.     obs.obs_properties_add_bool(props, "boolAutoquit", "Autoclose on OBS quit? \n(Only works with .exe)")
  19.  
  20.     obs.obs_properties_add_button(props, "launchButton", "Launch", launch_func)
  21.    
  22.     return props
  23. end
  24.  
  25. -- A function named script_description returns the description shown to
  26. -- the user
  27. function script_description()
  28.     return "Starts an executable then OBS is started.\n\nV0.4  \n\nMade by Davi Be"
  29. end
  30.  
  31.  
  32. -- A function named script_defaults will be called to set the default settings
  33. function script_defaults(settings)
  34.     obs.obs_data_set_default_string(settings, "execPath", "")
  35. end
  36.  
  37. -- A function named script_update will be called when settings are changed
  38. function script_update(settings)
  39. end
  40.  
  41.  
  42. -- a function named script_load will be called on startup
  43. function script_load(settings)
  44.     localSettings = settings
  45.     launch_func()
  46. end
  47.  
  48. -- save additional data not set by user
  49. function script_save(settings)
  50. end
  51.  
  52. -- function will be called just before OBS quits
  53. -- quit programm when exiting OBS
  54. function script_unload()
  55.  
  56.     -- assemble command    
  57.  
  58.     if obs.obs_data_get_bool(localSettings, "boolAutoquit") then
  59.         for i=0, #execNames do
  60.             cmd = 'taskkill /IM "' .. execNames[i] .. '"'
  61.             -- execute command
  62.             os.execute(cmd)
  63.         end
  64.     end
  65.    
  66. end
  67.  
  68. function launch_func()
  69.     --execPath = obs.obs_data_get_string(localSettings, "execPath")
  70.     array = obs.obs_data_get_array(localSettings, "execList")
  71.     count = obs.obs_data_array_count(array)
  72.     execNames = {}
  73.     for i = 0, count do
  74.         local item = obs.obs_data_array_item(array, i)
  75.         local itemname = obs.obs_data_get_string(item, "value")
  76.         if(itemname == "") then break
  77.         else do
  78.             execPath = itemname:gsub("/", "\\")
  79.             index = execPath:match'^.*()\\'
  80.             execDir = execPath:sub(1,index)
  81.             execName = execPath:sub(index + 1, execPath:len())
  82.             execNames[i] = execName
  83.             cmd = 'start "" /D "' .. execDir .. '" "' .. execName .. '"'
  84.             os.execute(cmd)
  85.         end
  86.         end
  87.     end
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement